Centuries from Younis Khan and Asad Shafiq have thwarted South Africa as Pakistan made 253-5 on the opening day of the second Test.
The hosts looked set for another breathtaking bowling display when they had Pakistan at 33-4 after just 17 overs in Cape Town.
But Younis (111) and Shafiq (111 not out) curtailed South Africa's bowlers with an impressive 219-run partnership for the fifth wicket.
Younis and Shafiq ensured Pakistan avoided repeating their embarrassing display in the first Test, when they were dismissed for just 49.
South Africa kept it tight early at Newlands, conceding just six runs from the first half-a-dozen overs on Thursday and the disciplined bowling paid off soon after.
Vernon Philander thought he had claimed the first wicket of the match on the second ball of the eighth over, but Faf du Plessis dropped Nasir Jamshed.
Du Plessis breathed a sigh of relief on the next delivery, as Jamshed edged Philander to wicketkeeper AB de Villiers to be out for three.
Dale Steyn was the next South African bowler to strike when Mohammad Hafeez was caught at slip by Graeme Smith for 17 and Morne Morkel plunged Pakistan into dire trouble when he claimed the scalps of Azhar Ali (four) and Misbah-ul-Haq (zero) in the 17th over.
Undeterred, Younis and Shafiq took control, guiding Pakistan to lunch without further loss and then attacking Robin Peterson during the middle session, hitting four boundaries and a six off the 33-year-old's spin bowling, which increased their confidence and led the team to 131-4 at tea.
Younis and Shafiq continued to rack up the boundaries after the tea break and the former was the first to reach triple figures, claiming the 21st century of his career with a sweep for two through square leg off Dean Elgar's bowling.
Shafiq followed two overs later; the 27-year-old right-hander cutting Elgar for four before South Africa took the new ball.
Younis survived an LBW shout from Steyn in the first new-ball over when the decision review system identified an inside edge.
But the 35-year-old veteran was left to curse the review system in the third-last over of the day when Smith went upstairs for an LBW appeal only to find Younis had edged Philander's delivery and De Villiers had caught it.
Shafiq and Sarfraz Ahmed (zero not out) steered Pakistan to stumps without further loss.
Philander finished the day in Cape Town with South Africa's best figures (2-45 off 21 overs), while Morkel (2-37 off 16) and Steyn (1-34 off 19) were the other main bowlers for the home team.