A typically belligerent stand between Azhar Ali and Misbah-ul-Haq in a frenetic third day hauled Pakistan back into the second test after South Africa owned the majority of Saturday at Newlands.
The pair took Pakistan to stumps on 100-3, which represented an overall lead of 112 after South Africa extended its first innings to 326 all out with some aggressive batting from the lower order.
Misbah was unbeaten on 36, while Ali was fortunate to be 45 not out after seeing Robin Peterson put down a return catch, and then umpire Steve Davis turn down an appeal for caught behind when replays suggested Ali edged a Vernon Philander delivery late in the day.
The unbroken 55-run partnership came in more than 28 overs, as the pair patiently rebuilt the innings following another Pakistan top-order collapse to leave the match intriguingly placed with two days remaining.
"I think it's pretty evenly poised at the moment," Peterson said. "I don't think you want to be chasing anything over 300 here, and hopefully we won't need anything more than 250."
Pakistan's conservatism in the third session was in contrast to the manner in which South Africa went about its business in the first two.
Pakistan would have harbored hopes of a much bigger first-innings lead given that it had South Africa 139-5 overnight, but the Proteas' decision to adopt a more positive approach on day three paid dividends.
Although the hosts lost a few wickets in taking the attack to the bowlers, they also scored 187 runs in 42 overs to reclaim the initiative, with Peterson hitting a career-best 84 from just 106 deliveries.
AB de Villiers' breezy 61 was the other highlight of the innings, but the two batsmen found plenty of support from the lower order as the last five wickets of the innings brought 217 runs.
"We are a little bit disappointed. We had a chance to get a really good lead, but there are some new guys playing in this game," Pakistan bowling coach Mohammad Akram said.
"We still managed to gain a lead, which is important, and we're still in this game, which is even more important."
Despite gaining a slender first-innings lead, Pakistan began its second innings with momentum against it, and was swiftly reduced to 7-2 in the first nine deliveries.
Dale Steyn and Vernon Philander grabbed a wicket each in their opening overs, dismissing Mohammad Hafeez and Nasir Jamshed for ducks respectively, before Steyn had Younis Khan play on in the first hour after the tea break.
"When the ball is moving we do struggle a bit. We're working hard at it," Akram said. "When you're facing the best two bowlers in the world it's always hard, but they're trying their best."
At 45-3, the balance of power was clearly in South Africa's favor, but Ali and Misbah came together to even the scales.
The Proteas were also dealt a blow when Morne Morkel limped out of the attack with a recurrence of the hamstring strain that affected him on Friday.
South Africa manager Mohammad Moosajee, who is also a medical doctor, confirmed Morkel would be unable to bowl again in the match, and is a doubt for the third test at Centurion, which starts on Friday.
What do you make of the decision to ban Kane Williamson from bowling?