Misbah made 80 and Imran Farhat scored 93 as Pakistan chased down South Africa’s total of 234 for nine with eight balls to spare.
Misbah and opening batsman Farhat shared a 153-run fourth wicket partnership after Pakistan had been struggling at 33 for three after 11 overs.
The early wickets included that of Mohammad Hafeez, who was given out for obstructing the field. He changed direction and was hit on the leg by a throw from South African wicketkeeper and captain AB de Villiers, who was throwing at the stumps at the bowler's end when Hafeez was several metres out of his ground.
Hafeez was only the fourth batsmen — and the third Pakistani — to be dismissed for obstructing the field in one-day internationals. Earlier, South Africa struggled despite a fourth wicket stand of 115 between captain De Villiers (75) and David Miller (67).