The 34-year-old claimed the final four wickets to fall, taking his tally to seven in the test, as the tourists were dismissed for 245, which set Pakistan a modest victory target of 88.
The hosts had a wobble when Anrich Nortje removed two batsmen in one over, but skipper Babar Azam (30) and Azhar Ali (31 not out) eased their side to a comprehensive victory in a match in which fortunes fluctuated until a burst of wickets for Pakistan late on the third day turned the game in their favour.
The second and final test starts in Rawalpindi on Thursday. South Africa will also play three Twenty20 Internationals on the tour, their first in Pakistan since a militant attack on the Sri Lanka team bus in Lahore in 2009, in which six policemen and two civilians were killed.
(Reporting by Nick Said; Editing by Kevin Liffey)