South Africa lost two wickets, but were on target for a series-clinching win after a dramatic Pakistan collapse on the fourth day of the second Test at Newlands in Cape Town yesterday.
South Africa, set 182 to win, were 66-2 at tea.
Pakistan were bowled out for 169 after starting the day on a relatively comfortable 100-3.
They lost their last six wickets for 22 runs on either side of lunch. At one stage, four wickets fell in 13 balls, including three off successive deliveries.
The collapse was engineered by left-arm spinner Robin Peterson and opening bowler Vernon Philander, who took three wickets each, before Dale Steyn finished off the Pakistan innings.
Peterson finished with three for 73 and Philander took four for 40.
South Africa lost Alviro Petersen 10 runs into their chase when he was leg before wicket to Umar Gul for 1.
Captain Graeme Smith and Hashim Amla put on 53 for the second wicket, before Smith was leg before to Saeed Ajmal for 29 shortly before tea.
Pakistan made slow, but solid progress, seeing off the threat of fast bowlers Philander and Dale Steyn, but they had only added 14 runs in 8.2 overs to their overnight total when captain Misbah-ul-Haq top-edged a sweep against left-arm spinner Peterson and was caught by Smith at short fine-leg for 44.
Azhar Ali and Asad Shafiq added 33 for the fifth wicket, before Shafiq was unlucky to see a defensive stroke against Philander bounce up and then back on to his stumps.
The wicket fell five overs after the umpires called for a replacement ball after the original went out of shape.
Peterson bowled Sarfraz Ahmed, who padded up to a ball pitched outside leg-stump, with the last ball of the next over.
Philander then took wickets with the first two balls of the following over.
A long vigil by Azhar Ali ended when he edged an outswinger to wicketkeeper A.B. de Villiers. Ali made 65 off 193 balls with seven fours.
Umar Gul edged the next ball and Alviro Petersen flung himself to his left at third slip to take a spectacular catch.
Tanvir Ahmed and Saeed Ajmal lasted until lunch, which was taken at 157-8.
Ajmal was bowled by Peterson, attempting a sweep, before Mohammad Irfan fended a short ball from Steyn to gully.
Philander, who took five for 59 in the first innings, had match figures of nine for 99.