Ashwell Prince and Jacques Kallis scored half centuries to guide South Africa to a fighting 259 for six wickets against Pakistan on the first day of the second Test at the Gaddafi stadium on Monday.
Prince (63) and AB de Villiers (45) were out in the final session to leave the match on an even keel after a slow but hard day on a pitch that had bounce and encouragement for the bowlers.
Mark Boucher was not out on nine and Andre Nel yet to score when bad light ended play seven overs before the close of play.
Prince was bowled by left arm spinner Abdul Rehman, who beat him in the air and turned one in sharply, after a patient innings that spanned 132 balls and 180 minutes with five fours.
He put on 83 for the fifth wicket with de Villiers, who was caught out of his crease as a drive by Boucher was deflected by bowler Mohammad Asif on to the stumps.
South Africa were 47 for two after losing Herschelle Gibbs (13) and Hashim Amla (10) in the first session to Umar Gul and Mohammad Asif.
But Prince anchored the innings after Kallis made a fluent 59 runs to follow up on his two centuries in the first test win in Karachi.
Leg spinner Danish Kaneria, who bowled 27 overs from one end, grabbed the wickets of captain Graeme Smith (46) and Kallis.
South Africa (1st innings):
H Gibbs c Misbah-ul-Haq b Gul 13
G Smith b Kaneria 46
H Amla b Asif 10
J Kallis lbw b Kaneria 59
A Prince b Rehman 63
AB de Villiers run out 45
M Boucher not out 9
A Nel not out 0
Extras: (w-2, nb-7, 5 penalty runs) 14
Total: (six wickets, 83 overs) 259
To bat: Paul Harris, Makhaya Ntini, Dale Steyn.
Fall of wkts: 1-24, 2-47, 3-100, 4-160
Bowling: Mohammad Asif 23-5-55-1, Umar Gul 18-1-78-1 (w-2, nb-6), Danish Kaneria 27-4-73-2, Abdul Rehman 10-3-28-1, Shoaib Malik 5-0-20-0 (nb-1).
Pakistan team: Shoaib Malik (captain), Inzamam-ul-Haq, Mohammad Yousuf, Younis Khan, Salman Butt, Kamran Akmal, Danish Kaneria, Abdur Rehman, Mohammad Asif, Umar Gul, Misbah-ul-Haq.