Fast bowler Hasan Ali's maiden Test 10-wicket haul gave Pakistan their first series win over South Africa in 18 years as they beat the Proteas by 95 runs in the second match on Monday.
Hasan, who bagged five wickets in the first innings, tormented the Proteas again returning figures of 5-60 and South Africa collapsed to 274 all out after lunch on the last day.
The last time Pakistan beat South Africa in a Test series was in 2003 when they won 1-0 at home.
Aiden Markram hit a resolute 108 — the opener's first Test hundred in almost three years — and Temba Bavuma made 61 before Hasan got two wickets off two deliveries with the second new ball to spark the collapse.
Markram and Bevuma put on 106 runs for their fourth-wicket stand and had given South Africa hope of chasing down the 370-run target after the Proteas resumed on 129-1.
But Hasan had Markram and captain Quinton de Kock caught at second slip off successive deliveries and South Africa lost their last seven wickets for just 33 runs after lunch.
Shaheen Afridi mopped up the tail with 4-51 before legspinner Yasir Shah brought up the victory by clean bowling Wiaan Mulder for 20.
Markram hit 13 fours and three sixes in his 5 1/2-hour stint at the crease but once Hasan provided the twin breakthrough, South Africa lost wickets in bunches as they did in Karachi where the visitors lost the first Test by seven wickets.
Pakistan rose to No. 5 in the ICC Test rankings for the first time, their highest position since 2017, while South Africa slipped to No. 6.