Centuries by Younis Khan and Asad Shafiq transformed Pakistan's fortunes on the first day of the second Test against South Africa at Newlands on Thursday.
Pakistan were 253 for five at stumps, having been reeling at 33 for four after being sent in.
Younis was caught behind off Vernon Philander 13 balls before the close for 111, while Shafiq was unbeaten, also on 111.
The pair put on 219, a record partnership for any wicket by Pakistan against South Africa.
It was a remarkable turnaround after the South African fast bowlers scythed through their top order early in the day.
Pakistan seemed in danger of another humiliation following their dismissal for a record low of 49 on the way to a 211-run defeat in the first Test in Johannesburg.
Graeme Smith's decision to bowl was prompted by cloudy weather, which followed early morning rain.
It seemed fully justified as Morne Morkel took two wickets and Philander and Dale Steyn claimed one each, with none of the batsmen looking comfortable.
Pakistan 253/5 in 90 overs (Younis Khan 111, Asad Shafiq 111*, V Philander 2/45, M Morkel 2/37)