Chasing a competitive 258 to win, Pakistan overhauled the target with just three balls to spare with former captain Malik playing the match-winning knock in 43 balls.
Pakistan required 10 runs from the last over and Malik dispatched pacer Aftab Alam for a six and four after playing a dot ball.
Wickets kept falling for Pakistan with star Afghan spinner Rashid Khan yet again proving his worth with a three wicket haul, but Malik held his nerves to keep one end tight.
Before Malik, Imam-ul-Haq (80) and Babar Azam (60) hit patient half-centuries in a 154-run stand but the slow run rate made it difficult for Pakistan.
Electing to bat, Hashmatullah Shahidi (97) missed out on his maiden ODI hundred by just three runs after skipper Asghar Afghan hit a combative 67 off 56 balls as Afghanistan scored a fighting 257 for six.
Their 94-run partnership and some terrific batting towards the end by the Afghans made it an interesting contest as they scored 87 runs in the last 10 overs.
Pakistan made a shaky start, losing opener Fakhar Zaman in the sixth ball of the innings, bowled by Mujeeb ur Rahman, but after that Azam and Imam took control of the proceedings, though the run-rate was always shooting up.
At the half-way mark, Pakistan had put on board just 103 for one with the required rate going beyond six, but they had the cushion of nine wickets.
The two batsmen put on 154 runs for the second wicket before Imam was run out in the 34th over. It was Najibullah Zadran's direct hit which found Imam short. His 80-run knock came off 104 balls with four shots to the fence and one over the ropes.
Nine balls later, Rashid Khan had Azam stumped. At this point, Pakistan needed exactly 100 runs from 15 overs.
Pakistan lost Haris Sohail (13), Sarfraz Ahmad (8), Asif Ali (7) and Mohammad Nawaz (10) with the Afghan bowlers fighting hard.
In the end, former captain Malik's experience saw them cross the finish the line.
Earlier, Shahidi needed a boundary off the last ball to complete his century but Hasan Ali denied him the milestone with a incoming yorker which the left-hander could not put away.
With his skipper Asghar, Shahidi shared a match-changing 94-run stand for the fourth wicket.
Shahidi shifted gears with ease after largely remaining patient in his unbeaten and career-best knock, which came off 118 balls. Five of his seven boundaries came during the last 14 balls of the Afghan innings.
Asghar had joined left-handed Shahidi at the crease after left-arm spinner Mohammad Nawaz (3/57) removed the top three Afghan batsmen - Mohammad Shahzad (20), Ihsanullah (10) and Rahmat Shah (36).
In his 67-run knock, Asghar showed both aggression and patience and Shahidi was determined, holding one end tight.
Asghar chose right deliveries to go for big shots, hitting five sixes and two fours.
Shahidi and Asghar were tested by the Pakistan pace duo of Hasan Ali and Usman Khan but they refused to be intimidated by the raw pace.
With the breakthrough not coming, Pakistan captain Sarfraz handed the ball back to Nawaz but Asghar hit 11 runs off his over which included a four and six, to end the long boundary drought.
Both the batsmen completed their half-centuries in the 40th over, bowled by young left-arm pacer Shaheen Afridi.
With few overs left, Asghar started hitting each everything thrown at him and was bowled by Afridi after being dropped by Haris Sohail in the 42nd over.
First Published: September 22, 2018, 8:10 AM IST