Pakistan produced disciplined cricket to upstage South Africa by six wickets in the third day-night international here on Tuesday to take a 2-1 lead in the series.
Rao Iftikhar made a career-best 3-33 and leg-spinner Shahid Afridi 3-37 to restrict the tourists to 197 all out.
Mohammad Yousuf then hit an unbeaten snail-paced 58 off 113 balls to help Pakistan reach 202-4 in 48.1 overs.
Yousuf added an invaluable 79 runs for the fourth wicket with captain Shoaib Malik (42) to set up the victory. Yousuf hit just one boundary in his half-century but stayed until the victory was achieved.
It followed a contrasting cameo by Afridi who enthralled the 16,000-strong crowd at Iqbal Stadium with a rapidfire 32.
Afridi gave Pakistan a fiery start when he hit two sixes and four boundaries in his 18-ball knock before Pakistan lost three quick wickets.
Afridi's ferocious shot off Shaun Pollock was held by Graeme Smith before Yasir Hameed (18) fell to Makhaya Ntini and Younis Khan (10) was caught behind off Albie Morkel.
Morkel also broke the Malik-Yousuf stand. But with only 51 needed for victory it was too late for South Africa as Misbah-ul Haq (29 not out) helped Yousuf complete the formality.
Malik paid tribute to his team as they edged ahead in the five-match series.
"We overcame fielding problems and this was a complete team effort. Now after this win we are determined to win the series," said Malik, whose team won the second match by 25 runs.
South Africa won the first match by 45 runs.
Captain Smith said South Africa had failed to get a solid total.
"We couldn't put partnerships (together) in the middle overs and had we scored 20-30 more runs it could have been interesting," said Smith.
Earlier, Iftikhar and Afridi shared six wickets to derail South Africa, which won the toss and elected to bat.
Afridi dismissed Jacques Kallis (13), Justin Kemp (42) and Shaun Pollock (one) to trigger a middle-order slump from which they could not recover.
South Africa, reduced to 77-3 in 20 overs, was lifted by Smith (48) and Kemp, who shared a fourth-wicket stand of 45 off 75 deliveries but they never looked in command.
Herschelle Gibbs, who scored a century in the first match, fell in the ninth over when he edged Umar Gul to the wicketkeeper after scoring 19.
Gibbs, on ten, completed 7,000 one-day runs, to become only the second South African behind Kallis to achieve the milestone.
Kallis, who made eight and nought in the first two matches, failed once again as he miscued a drive off Afridi and was well caught in the covers by Misbah-ul Haq for 13.
AB de Villiers made just 17 before his uppish drive off Iftikhar was smartly snapped up by Afridi at mid-wicket.
Smith and Kemp steadied the innings, taking the score to 122.
Smith, who remained on 18 for ten overs, was run out in the 33rd over when he failed to beat a throw from Shoaib Malik to the striker's end.
Kemp hit two sixes to raise the tempo before he went for a third only to be bowled by Afridi in the 42nd over.
Iftikhar returned for his second spell, removing Albie Morkel (12) and Charl Langeveldt (four) to better his 3-44 he took against the West Indies at Kingston during the 2007 World Cup in march this year.
South Africa lost Mark Boucher (17) to spinner Abdul Rehamn as the tourists lost their last six wickets for just 35 runs.
The fourth match will be played at Multan on Friday.