Medium pacer Hasan Ali took a maiden ten-wicket haul to help Pakistan win its first series against South Africa since 2003 with a 95-run victory in the second Test on the fifth and final day in Rawalpindi on Monday.
Hasan finished with 5-60 to record his best match figures of 11-114 and help dismiss South Africa -- who were set a daunting 370 to chase -- for 274 before the tea break.
Hasan's new-ball partner Shaheen Shah Afridi finished with 4-51, while spinner Yasir Shah took the last wicket to spark jubilation among the Pakistan players.
Opener Aiden Markram scored a fighting 108 and Temba Bavuma 61.
They put on a 106-run stand for the fourth wicket to give Pakistan a scare.
Markram took a single off the last ball before lunch as South Africa reached the break on 219-3, needing 151 for a win.
But Hasan ripped through the tourists' batting order, which lost seven wickets for just 33 runs with the second new ball.
Hasan struck with the second over of the new ball to end Markram's resistance by getting the opener caught in the slip and end his 335-minute fight.
Markram's fifth Test century -- the first outside South Africa -- included 13 boundaries and three sixes.
Next ball, Hasan had Quinton de Kock caught in the slip for nought, ending the South African skipper's miserable series with just 46 runs.
Pakistan skipper Babar Azam was delighted with the win.
"Thanks to South Africa for coming and playing competitive cricket," said Azam. "Hasan's comeback after one year was great and he showed great character."
Hasan was sidelined for more than a year with multiple injuries but came back strongly with 12 wickets in the series.
Azam admitted South Africa's resistance provided a tough challenge for his side.
"At one time, we thought the game could've gone either way when Markram and Bavuma were playing well. But we knew, one wicket and we can come back into the game again," he said.
Losing captain Quinton de Kock said his team lacked a killer touch.
"The first-innings deficit did play a big part," said de Kock. "We lost the big moments in the game and that cost us. It's painful at the moment.
"When we get back home, we'll have to look at our performances and improve on the way forward."
- Historic win -
Hasan dismissed George Linde for four to record his third five-wicket haul as he improved upon his previous best match figures of 7-83 against New Zealand in Abu Dhabi in 2018.
In the morning, both teams were involved in a keen battle for victory as South Africa resumed on 127-1, knowing the best chase at Rawalpindi Cricket Stadium in ten previous Tests was the 200 scored by Sri Lanka in 2000.
South Africa saw Dussen bowled off a beautiful inswinger by Hasan -- only the third ball of the day -- while Du Plessis was leg-before to the same bowler in the fifth over of the morning.
It capped a sub-par series for the experienced Du Plessis who managed just 55 in four innings.
This is Pakistan's only second Test series win over South Africa in 12 attempts, having lost eight and drawn three.
Pakistan last beat South Africa 1-0 in a two-match series at home in 2003.
Pakistan won the first Test by seven wickets in Karachi.
The series against South Africa -- who were touring Pakistan for the first time in 14 years -- is the biggest hosted by the home side since a deadly 2009 militant attack on Sri Lanka's squad in Lahore halted international tours.
The series win also lifts Pakistan to fifth in international Test rankings -- the first time they have placed in the top five since January 2017.
South Africa are pushed to sixth from fifth.
The two teams will now play three Twenty20 internationals on February 11, 13 and 14, all in Lahore.