The Lahore Test entered a crucial stage on Tuesday as South Africa, chasing a 277-run target, reached 51 for the loss of two wickets at stumps.
A total of 16 wickets fell on the third day, leaving the match delicately poised — with the Proteas needing 226 runs for victory and Pakistan requiring eight wickets to win.
Earlier in the day, South Africa added 53 runs to their overnight total before being bowled out for 269.
Resuming on 216 for six on the third day, the visitors managed to add just 53 runs before losing their remaining wickets.
Tony de Zorzi top-scored for South Africa with a gritty 104, while Ryan Rickelton made 71.
From the home side, Nauman Ali starred with six wickets, while Sajid Khan took three and Salman Ali Agha chipped in with one.
However, Pakistan’s second innings collapsed under tight South African bowling. Spinner Mutusamy took five wickets while Harmer claimed four as Pakistan were bundled out for 167.
Babar Azam top-scored for Pakistan with 42 runs, while Abdullah Shafique made 41, Saud Shakeel 38, Mohammad Rizwan 14, and Nauman Ali 11.
Shan Masood was dismissed for 7, Salman Ali Agha for 4, Sajid Khan for 1, while Imam-ul-Haq and Shaheen Shah Afridi fell without scoring.
Set a target of 277, South Africa lost two early wickets before Ricketton and De Zorzi steadied the innings, taking their side to 51 for two at the close of play.