Abu Dhabi - AB de Villiers and Jacques Kallis rescued South Africa with sparkling hundreds to guide them to 311/5 at close on the first day of the second Test against Pakistan on Saturday.
De Villiers was unbeaten on 120 for his 11th hundred while Kallis notched 105 for his 37th, as the duo added 179 runs for the fourth wicket after debutant paceman Tanveer Ahmed shook South Africa with three early wickets.
Mark Boucher was unbeaten on 26 at stumps.
Ahmed (4-67) had justified Pakistan captain Misbah-ul-Haq's decision to bowl first with South Africa tottering at 33/3 but Kallis and De Villiers thwarted any attempts in the next two sessions.
Kallis, 34, was more dominant during the restorative stand, hitting 12 boundaries and three towering sixes during his 147-ball knock before he played on to Ahmed in the first over after tea.
Kallis is behind India's Sachin Tendulkar (49) and Australia's Ricky Ponting (39) in the all-time Test century-makers list.
De Villiers, 26, ably supported his senior partner as Pakistan failed to get the duo in trouble.
De Villiers has so far hit eleven fours and a six during his attractive 231-ball knock.
In the morning, Ahmed struck three crucial blows in the morning session, removing Alviro Petersen (two) off the third ball of his Test career and then claiming Hashim Amla (four) off his eighth and Graeme Smith (10) in his sixth over - claiming three wickets off 28 balls.
Petersen edged Ahmed to first slip where Misbah took a well-judged catch before Amla was adjudged caught behind by Sri Lankan umpire Asoka de Silva, despite television replays showing that the ball brushed the batsman's pad.
Smith, who took 20 balls to open his account, edged Ahmed to wicketkeeper to leave the fight to Kallis and De Villiers.
In-form Kallis, who hit 73 and 135 not out in the drawn first Test in Dubai, took three off paceman Umar Gul before he ran for a single off spinner Abdul Rehman in the next over to complete his hundred off 135 deliveries - his fifth this year.
The Kallis-De Villiers stand is a new record for the fourth wicket partnership against Pakistan, erasing the previous best of 119, involving Kallis and Amla at Centurion in 2007.
After Kallis was dismissed in the first over after tea, De Villiers added another 56 for the fifth wicket with Ashwell Prince (32).
Pakistan took the second new ball after 82 overs with the South African score 285-5, but De Villiers and Boucher remained firm.
Pakistan, who lost paceman Wahab Riaz because of a side strain, were forced to make three changes. They dropped Umar Akmal - penalised for his rash shot in the first Test - along with off-spinner Saeed Ajmal.
Ahmed and Asad Shafiq, also making his debut, and Mohammad Sami were brought in, while South Africa chose the same first Test XI.
Scores at stumps:
South Africa 1st innings
G. Smith c Adnan b Ahmed 10
A. Petersen c Misbah b Ahmed 2
Hashim Amla c Adnan b Ahmed 4
J. Kallis b Ahmed 105
AB de Villiers not out 120
A. Prince c Shafiq b Hafeez 32
M. Boucher not out 26
Extras (b6, lb1, nb5) 12
Total (for five wkts, 90 overs) 311
Fall of wickets: 1-2 (Petersen), 2-6 (Amla), 3-33 (Smith), 4-212 (Kallis), 5-268 (Prince)
Bowling: Umar 21-5-60-0, Ahmed 16-2-67-4 (4nb), Sami 14-1-69-0, Younis 3-1-11-0 (1nb), Rehman 29-7-77-0, Hafeez 7-0-20-0
Umpires: Daryl Harper (AUS) and Asoka De Silva (SRI)
TV umpire: Nadeem Ghouri (PAK)
Match referee: Andy Pycroft (ZIM)