Vernon Philander and Robin Peterson both took three wickets as Pakistan lost their remaining seven wickets for 69 runs, including three in three balls, to set South Africa a target of 182. Philander's three wickets saw him finish with innings figures of four for 40 while Peterson ended with three for 73.
In response, South Africa were 66 for two at tea, Alviro Petersen (one) and Graeme Smith (29) the men out, with the hosts requiring another 116 runs for victory. The tourists had resumed 112 runs ahead with seven second-innings wickets intact, Misbah-ul-Haq and Azhar Ali having forged a steady partnership.
Misbah correctly survived an appeal for a catch at slip while Azhar reached a half-century but was then soon dismissed, a key wicket for South Africa. From a Peterson delivery, Misbah got a top edge and Smith took a simple catch at short fine leg to reduce Pakistan to 114 for four. Misbah had made 44 off 111 deliveries including three sixes and four fours.
Asad Shafiq came to the crease and showed attacking intent but he was soon out in unfortunate fashion as the ball spun backwards from a Philander delivery and removed the off bail. Asad had made 19 off 29 balls including three fours but his dismissal left Pakistan on 147 for five.
Replacement Sarfraz Ahmed had made just five off nine deliveries before he left a Peterson delivery which pitched outside leg but skidded and hit the middle stump. South Africa claimed the vital wicket of Azhar from the very next delivery at the start of the new over.
Azhar got a thick outside edge to a Philander ball which was pounced on by AB de Villiers to his right. He had played a steady innings of 65 from 193 balls that included seven boundaries.
South Africa then claimed a third dismissal in successive deliveries as Umar Gul went for a golden duck, with Alviro Petersen taking a sharp catch off Philander. Tanvir Ahmed and Saeed Ajmal were at the wicket but in the first over after lunch the latter was removed for four by Peterson with just six more on the board.
Mohammad Irfan came to the wicket but he was caught by Petersen off Dale Steyn for two and Pakistan's innings was over. South Africa's response was interrupted when Petersen was lbw to Umar for just one.
However, Smith wasted no time setting about the bowlers and, once Hashim Amla had settled, they forged an effective partnership which was halted with the score on 63 when Smith was lbw to Saeed Ajmal. The Proteas captain had made 29 from 39 balls including two boundaries.