Aiden Markram (59 batting) and Rassie van der Dussen (48 batting) batted well to give South Africa hope of an improbable win in the second Test here on Sunday.
Set a daunting 370-run target, South Africa finished the fourth day on 127 for one, needing another 243 runs to level the series.
Earlier, Pakistan was helped to 298 in its second innings by a scintillating maiden hundred by wicketkeeper-batsman Mohammad Rizwan (115 n.o., 15x4).
South Africa’s left-arm spinner George Linde recorded his first five-wicket haul.
The scores: Pakistan 272 and 298 (Mohammad Rizwan 115 n.o., Nauman Ali 45, George Line 5/64) vs South Africa 201 and 127/1 in 41 overs (Aiden Markram 59 batting, van der Dussen 48 batting).