Pakistan have reached stumps on 100-3 after an intriguing third day of the second Test against South Africa in Cape Town.
The hosts rallied in the morning session to begin the afternoon on 248-7 and steadily improved to eventually post a total of 326.
Robin Peterson ended with a career-best score of 84, while Vernon Philander provided support with a stubborn 22.
Pakistan's second innings started in disastrous fashion, with Dale Steyn trapping Mohammad Hafeez lbw from just the second ball of the bowler's opening spell.
Nasir Jamshed quickly followed his opening partner back to the dressing room after he was dismissed lbw by the dangerous Philander.
Steyn claimed his second wicket when Younus Khan (14) chopped the ball onto his own stumps, despite looking well set at the crease.
However, Azhar Ali (45*) and Misbah-ul-Haq (36*) guided the tourists to stumps and Pakistan will begin a crucial fourth day leading by 112 runs.