South African batsmen thwarted Pakistan's spin attack to reach 84-1 at tea on the third day of the first Test in Karachi on Thursday.
Earlier, Pakistan scored 378 to take a 158-run lead over South Africa's first innings total of 220.
At the break, Aiden Markram was on 34 and Rassie van der Dussen was on 17. The visitors need another 74 runs to avoid an innings defeat.
Markram, dropped on 27 by Pakistan skipper Babar Azam off spinner Yasir Shah in the slips, has added 36 for the second wicket with Dussen.
South Africa were off to a confident start with Markram and Dean Elgar defying Pakistan's attack, and were 37 without loss at lunch.
Elgar, in visible discomfort after being hit on the left hand by a rising delivery from pacer Shaheen Shah Afridi, was caught by diving wicketkeeper Mohammad Rizwan off Yasir for 29.
In the morning Pakistan's tail added 70 runs to frustrate South Africa, who were looking for quick wickets.
South Africa's pace spearhead Kagiso Rabada bowled Hasan Ali for 21 to reach 200 wickets in his 44th Test.
Rabada, 25, is the eighth South African to take 200 or more Test wickets.
Pakistan were 323-9 at that point, but Yasir and Nauman Ali added 55 valuable runs for the final wicket.
Yasir, who scored a Test century in Australia in 2019, hit a six and four fours in his 38 not out, while debutant Nauman scored three boundaries before falling for 24.
Rabada with 3-70 and spinner Keshav Maharaj, who took 3-90, were the pick of the South African bowlers.