Pakistan finally took the battle to South Africa but still face defeat heading into the fourth day of the first Test in Joburg.
Set an unfeasible 480 for victory following their hapless first innings collapse, the visitors reached 183-4 after the top-order mis-fired again.
Put back in by Graeme Smith before lunch after the Proteas skipper declared on 275-3, Pakistan lost Mohammad Hafeez in the fourth over when he edged Vernon Philander to 'keeper AB de Villiers.
Nasir Jamshed and Azhar Ali put on 57 - more than the entire first innings score - for the second wicket before the former fell to Dale Steyn four short of a half-century on his debut.
Ali (18) went lbw to Jacques Kallis shortly afterwards despite a review, and veteran Younis Khan could make only 15 before he edged Morne Morkel to de Villiers.
But skipper Misbah-ul-Haq (44 not out) and Asad Shafiq (53 not out) dug in with a resolute stand of 101, batting out the entire final session to frustrate the home attack.
Shafiq had a let-off on 40 when he edged Philander to Smith at first slip, only for the bowler to have been called for a no-ball.
In the following over, Misbah drove Kallis to backward point only for Robin Peterson to spill a waist-high chance on the dive.
Earlier in the day, de Villiers hurried to a century to leave Pakistan with an hour's batting before lunch. De Villiers needed only 33 balls to move from his overnight 63 to 103 not out.
He and Hashim Amla (74 not out) added 68 in nine overs before the declaration, which came immediately after de Villiers punched Umar Gul to the cover boundary to reach his 15th Test century off 117 balls.