South Africa fought back bravely on day three of the second test against Pakistan, but an unbeaten 55-run stand between Misbah-ul-Haq and Azhar Ali ensured the visitors are still very much in with a chance of leveling the series.
The Proteas started the day on 139 for five, still 199 runs behind Pakistan's 338. Spinner Saeed Ajmal, who had take all five of those wickets on day two, continued to torment the hosts, and Dean Elgar never looked comfortable.
He was sent packing on 24, adding 13 to his overnight score, when he was caught by Younis Khan in the slips to give Ajmal his sixth wicket. De Villiers then battle on to his second half ton against Pakistan, but was caught at mid on off a leading edge.
Robin Peterson then came to the crease and showed how much his batting had developed, taking advantage of some poor fielding by the visitors and using a relatively brisk 64 balls to reach his 40 at lunch. Vernon Philander was the other man in the middle, having made 11.
Peterson continued his assault in the afternoon, batting unlike anyone else had managed to do and allowing the tail to wag, just as Pakistan had done. He continued on his boundary spree as others fell around him, inching ever closer to Pakistan's 338.
Peterson was eventually the final man to fall, ending the Proteas' innings on 326 and ensuring a deficit of just 12 runs.
Peterson ended with 84 runs - his highest ever test total - which included 15 fours. Morne Morkel also added some nifty shorts at the end to push the score close to the requirement ahead of the Pakistani second innings.
With honours even, South Africa's pace attack appeared to seize the initiative as both Dale Steyn and Vernon Philander struck with the new ball to reduce Pakistan to just 7/2.
Steyn's wicket came in just the second ball of the innings, trapping Mohammad Hafeez in front with a beautiful inswinger.
The opener departed for a duck, and Nasir Jamshed soon followed him back into the dressing room when Philander struck in the very next over, also trapping his victim in front.
Jamshed briefly considered the review, but with the ball pitching in line and clipping the top of the stumps, he was wise to turn it down.
With Nos 3 and 4 Azhar Ali and Younis Khan finding themselves at the crease after just nine balls of Pakistan's second innings, it looked like another batting collapse might be on the cards.
The duo played solidly, however, negotiating the new ball successfully and returning after tea to put on 38 runs before Steyn struck again in the 15th over.
The Proteas paceman bowled a few balls short at Khan and then followed it up with a fuller length delivery that trapped him at the crease. The first innings centurion dragged the ball onto his stumps to depart for 14 runs and once again put South Africa on top.
The rest of the day's play belonged to Pakistan, however, as Misbah joined Ali at the crease with the score at 45/3 for an unbeaten 55-run partnership that took Pakistan's total to 100/3 at stumps - a lead of 112 runs with seven wickets still in hand.
With a pitch that will only provide more assistance to Ajmal as the match progresses, South Africa will have to strike early and often on day four, or risk chasing a total of 250 plus in tough conditions on the final day.