Shan Masood and Asad Shafiq shared a century partnership as Pakistan fought to avoid an innings defeat on the third day of the second Test against South Africa at Newlands on Saturday.
Facing a first innings deficit of 254 runs, Pakistan were 177 for three in their second innings at tea, 77 runs short of making South Africa bat again.
The left-handed Masood made 61 and Shafiq was 73 not out.
The pair put on 132 for the third wicket after Pakistan had been reduced to 27 for two after strikes by Dale Steyn and Kagiso Rabada.
Masood, who was promoted to open the batting in place of the struggling Fakhar Zaman, again looked the most organised of the Pakistan batsmen before he was caught behind off Steyn shortly before tea.
The slightly-built Shafiq played a wide variety of attacking strokes as he hurried to a half-century off 56 balls with seven fours and a six. Pakistan added 140 runs for the loss of Masood’s wicket in 25 overs between lunch and tea.
Earlier, Mohammad Amir took three wickets for 19 runs as South Africa were bowled out for 431, losing their last four wickets while adding 49 runs in 8.1 overs.
The left-armed Amir took the first three wickets of the morning and finished with four for 88.