The outcome of the second Test between South Africa and Pakistan remains in the balance after a fascinating third day's play in Cape Town.
Pakistan reached stumps well-set on 100-3 in their second innings, an overall lead of 112, after earlier restricting South Africa to 326 all out in their first knock.
Resuming on 139-5, the Proteas battled towards parity thanks to Robin Peterson's career-best 84 and a half-century from AB de Villiers (61).
The hosts took their momentum into the field, bt, despite reducing Pakistan to 7-2 early on, the visitors recovered well through Azhar Ali (45no) and Misbah-ul-Haq (36no) to reignite hopes of a first Test victory in South Africa since January 2007.
Pakistan spin king Saeed Ajmal had ripped through South Africa's top order on Friday and when Dean Elgar (23) edged a loose drive straight to Younus Khan at slip early on day three, the spinner had taken all six wickets to fall.
That came just after De Villiers was dropped on 37 by Azhar, a sharp chance at gully, and he pulled Ajmal for his sixth boundary to bring up a 91-ball half-century.
But his innings ended when a leading edge off 7ft 1in paceman Mohammad Irfan spooned straight to Umar Gul at mid-on. He had put on 55 with Elgar and 46 with Peterson, who then added a further 67 with Vernon Philander.
Peterson's second Test half-century came up with back-to-back boundaries off Tanvir Ahmed and he soon pulled Gul for his 10th four, a rare one through the leg side.
Philander added a useful 22 before being cramped by a short ball from Irfan, the ball looping to Nasir Jamshed at gully.
A late cut for four took Peterson to his highest Test score, passing the 61 he made against Bangladesh in May 2003 and he became the last man out with South Africa 12 runs in arrears when lifting Mohammad Hafeez straight to Umar Gul at long-on.
Irfan ended up with 3-86 on his debut while Ajmal took 6-96, but the Proteas' bowlers had a response up their sleeve.
Hafeez was trapped lbw by Dale Steyn with the second ball of the innings and opening partner Nasir Jamshed also failed to trouble the scorers before being pinned in front by Philander.
Azhar and Younus Khan took the score on to 45 before the latter slashed at a wider delivery from Steyn and chopped it on to his stumps.
But Azhar and Misbah then set about building a patient partnership, which was unbroken on 55 when stumps were called.