In their second innings, Pakistan were dismissed for 298 to give South Africa a challenging target of 370 to win the second test on Sunday’s fourth day of play in Rawalpindi.
Wicketkeeper-batsman Mohammad Rizwan, who scored a superb unbeaten 115 and expanded the home side’s overnight lead from 200 to 369, extended Pakistan’s lead to 129-6.
George Linde’s spinners ended with 5-64 figures and 3-118 was taken by Keshav Maharaj.
Pakistan were 217-8 at lunch with Rizwan on 73 and Nauman Ali batting on 10, respectively.
Since the start of the day’s play, with left-arm spinners Maharaj and Linde sharing wickets, the hosts had added 88 runs for the loss of Hasan Ali (five) and Yasir Shah (23).
When he was caught leg-before in the sixth over of the day, Hasan was the first to go, but Yasir helped Rizwan put on 53 in a resilient stand for the eighth wicket.
When the batsman was 15, Linde, who dropped Yasir off his own bowling, eventually had him caught by wicketkeeper Quinton de Kock behind to end the stand.
After winning the first Test in Karachi by seven wickets, Pakistan led the two-match series 1-0.