Khurram Manzoor's maiden Test century moved Pakistan into the lead on day two of the series opener against South Africa in Abu Dhabi.
Manzoor finished on 131 not out as Pakistan reached 263-3 in reply to South Africa's first-innings 249.
The opener put on a 135-run stand with debutant Shan Masood for the first wicket.
It took the introduction of part-time spinner JP Duminy (1-39) to make the breakthrough, Masood falling lbw for 75.
Azhar Ali (11) and Younus Khan (1) departed in quick succession early in the evening session, Ali caught behind off Vernon Philander (1-31) and Younus fending a sharp lifter from Morne Morkel (1-23) to Alviro Petersen in the gully.
Pakistan skipper Misbah-ul-Haq (44no) joined Manzoor in an 85-run partnership through to stumps.
Manzoor, playing in his 10th Test, brought up his hundred from 198 balls, including 11 fours and, by the close, had faced 244 deliveries and added a further three fours.
Misbah survived a couple of scares; South Africa were unsuccessful with a review for lbw after he was hit on the pad by Morkel when on nine, replays confirming the ball was going over the stumps.
And, after the second new ball was taken late in the day, the third umpire ruled Graeme Smith had not taken a clean catch at first slip after Philander found Misbah's edge.
South Africa, on 245-8 overnight, extended their innings for just 19 balls of the morning.
Hashim Amla failed to add to his 118, edging the second ball of the day from fast bowler Mohammad Irfan (3-44) to Younus at second slip and Dale Steyn (15) was stumped after giving off-spinner Saeed Ajmal (2-59) the charge.