Pakistan 272 (Ashraf 78*, Azam 77, Nortje 5-56, Maharaj 3-90) and 298 (Rizwan 115*, Linde 5-54) beat South Africa 201 (Bavuma 44*, Hasan Ali 5-54) and 274 (Markram 108, Bavuma 61, Hasan Ali 5-60, Afridi 4-51) by 95 runs
Rawalpindi: Pakistan completed a 2-0 series clean sweep over South Africa with a 95-run win in the second Test at Rawalpindi Cricket Stadium on Monday.
Resuming on 127-1 in pursuit of an improbable 370, South Africa were bowled out for 274 shortly before tea on the final day.
They lost their last seven wickets for 33 runs, a collapse sparked by opener Aiden Markram's dismissal for 108.
Hasan Ali took 5-60 to finish with 10-114 in the match, while fellow seamer Shaheen Afridi claimed 4-51.
Yasir Shah bowled Wiaan Mulder for 20 to seal Pakistan's first series victory over South Africa since 2003.
The sides play the first of three Twenty20s on Thursday.
Hasan removed Rassie van der Dussen with the third ball of the day - bowled via an inside edge for 48 - and four overs later trapped Faf du Plessis lbw for five.
But South Africa harboured slim hopes of pulling off the highest successful Test chase in Pakistan as Markram and Temba Bavuma, who made 61, added 106 for the fourth wicket.
Having spent almost six hours compiling his first Test century since 2018, Markram edged to second slip as he pushed at Hasan, who removed Quinton de Kock in almost identical fashion next ball.
De Kock has managed only 74 runs at an average of 12.33 since succeeding Du Plessis as captain in December.
When Afridi found Bavuma's edge, South Africa's prospects of even batting out the day to secure a draw were as good as over.