Mohammed Hafeez's half-century guided Pakistan to 144 for two in reply to South Africa's first innings 380 on the second day of the first Test on Saturday.
Opener Hafeez slammed a rapid 60 off 89 balls as Pakistan ended the day 236 runs behind.
Hafeez and Taufeeq Umar (42) put on 105 for the first wicket after taking advantage of some wayward new-ball bowling from Dale Steyn and Morne Morkel.
The duo brought up the 50 at a run-a-ball but were more circumspect after that.
Hafeez was the first to depart when he was caught at mid-on off left-arm spinner Paul Harris. Umar fell six runs later when he was trapped leg before by Morkel.
Earlier, South Africa's first innings ended 26 minutes after lunch when off-spinner Saeed Ajmal trapped Morkel leg before for 10.
Swing bowler Umar Gul picked up three for 100 while left-arm spinner Abdur Rehman claimed three for 101.
The morning session belonged to Pakistan as South Africa lost six wickets for 54 runs before lunch.
Gul was at the heart of the collapse, snatching three for 19 in 8.3 overs as he kept an excellent line just outside off stump and extracted just enough seam movement to trouble the batsmen.
Pakistan's performance in the field was all the better for the fact left-arm seamer Wahab Riaz was unable to bowl after straining his side on the opening day.
The team said the injury was severe enough to rule him out of the rest of the series.
South Africa, resuming on 311 for three, lost nightwatchman Harris early when he was caught at second slip off Gul for a duck.
Gul then produced a superb delivery which nipped back off the seam to bowl AB de Villiers for five through the gate before the 26-year-old trapped Ashwell Prince leg before for one.
Rehman then had Mark Boucher lbw for nine before Ajmal picked up the important wicket of Jacques Kallis.
Kallis, who had added 20 to his overnight 53, edged to keeper Adnan Akmal before Rehman bowled Johan Botha (10) with a turning delivery that clipped the top of the off stump.
South Africa first innings (overnight 311-3)
G Smith c Umar b Riaz 100
A Petersen c Younis b Rehman 67
H Amla c A Akmal b Riaz 80
J Kallis c A Akmal Saeed Ajmal 73
P Harris c Younis Khan b Gul 0
AB de Villiers b Gul 5
A Prince lbw Gul 1
M Boucher lbw Rehman 9
J Botha b Rehman 10
D Steyn not out 10
M Morkel lbw Ajmal 10
Extras: (b 9, lb 2, w 1, nb 3) 15
Total 380 (123 overs)
Fall of wickets: 1-153, 2-190, 3-307, 4-318, 5-327, 6-329, 7-345, 8-347, 9-363, 10-380.
Bowling: Gul 30-4-100-3 (1nb), Riaz 18-3-61-2 (1nb, 1w), Rehman 32-2-101-3, Ajmal 35-6-95-2, Hafeez 1-0-1-0, Younis Khan 7-2-11-0 (1nb).
Pakistan first innings
M Hafeez c Smith b Harris 60
T Umar lbw b Morkel 42
A Ali not out 12
Younis Khan not out 21
Extras: (lb 9) 9
Total: (two wickets; 55 overs) 144
Fall of wickets: 1-105, 2-111
To bat: Misbah-ul-Haq, U. Akmal, A. Akmal, A. Rehman, W. Riaz, S. Ajmal, U. Gul.
Bowling: Steyn 11-3-38-0, Morkel 10-3-38-1, Harris 20-6-34-1, Kallis 4-1-7-0, Botha 10-3-18-0.