Hasan Ali claimed his maiden 10-wicket Test match haul as Pakistan completed a 2-0 series whitewash of South Africa despite a century from Aiden Markram.
Seamer Hasan took 5-60 as the Proteas collapsed to 274 all out Rawalpindi Cricket Stadium on Monday, losing by 95 runs after looking poised to level the series.
Hasan finished with magnificent match figures of 10-114, inspiring Pakistan to a first series triumph over South Africa since 2003.
South Africa had been going along nicely on 241-3 chasing 370 to win, but the tourists fell apart after Markram was dismissed for a superb 108.
Markram's fifth Test hundred – and his first since March 2018 – proved to be in vain as Hasan was once again the star of the show on the final day.
Temba Bavuma made 61 and Rassie van der Dussen 48, but South Africa lost seven wickets for only 33 runs, Shaheen Shah Afridi also doing damage, taking 4-51.
Quinton de Kock fell for a golden duck, while Keshav Maharaj and Kagiso Rabada also failed to trouble the scorers.
Victory for Pakistan moved them up to fifth in the Test rankings and was their first series win since beating Bangladesh 12 months ago, bringing the Proteas back down to earth after their 2-0 defeat of Sri Lanka.
South Africa have now lost four of their past five series and are unable to respond with a victory over Australia on home soil after the series was postponed.
Hasan's Test-best stuns Proteas
South Africa could not contend with Hasan in the first innings and it was the same story on the final day of the series.
He saw the back of Van der Dussen and Faf du Plessis (five) in the morning session, then came to the party again with the second new ball
Hasan claimed the big wicket of Markram, who was caught by Imran Butt, then dismissed captain De Kock first ball before sending George Linde packing. Afridi also delivered for Pakistan, with Yasir Shah sealing victory by bowling Wiaan Mulder when he charged down the track.
Markam stakes captaincy claim
It proved to be a day to forget for the tourists, but Markram's knock was a major positive.
The opener showed his class, batting for over five and a half hours – hitting three sixes and finding the rope 13 times – as he staked his claim for the captaincy.