South Africa stuttered to a four-wicket win over Pakistan in their second Test at Newlands on Sunday.

Chasing 182 to win the match and take an unassailable 2-0 lead in the three-match series, the Proteas never appeared in real danger of losing the contest, but a consistent stream of wickets will be of concern to the South African brains trust.

South Africa's second innings efforts got off to a shaky start as Alviro Petersen - who had been caught off a no-ball just moments earlier - was trapped lbw for one in the fourth over by Umar Gul.

After Petersen's early dismissal, Hashim Amla and Smith took control with a half-century stand, but Smith fell to the wily Ajmal shortly before tea after he got his sweep all wrong, leaving the Proteas on 66 for two at the break.

Frustratingly for Gary Kirsten's outfit, Petersen aside, all of the top order got starts but couldn't remain at the crease long enough to steer the ship home.

Jacques Kallis became Ajmal's second victim of the day as he was trapped lbw for 21. Amla and AB de Villiers took the South African's within 32 runs of victory before the former played on off the bowling of the magnificent Ajmal after amassing 58.

A loose shot from de Villiers saw the wicketkeeper-batsman caught behind for 36 and then with just two runs required, Faf du Plessis became Ajmal's tenth scalp of the match as he was adjudged lbw.

Dean Elgar brought up the winning runs soon after and in doing so gave the Proteas an unassailable 2-0 series lead.

Much of the leg work for the victory had been done during the morning's session as South Africa's bowlers took control of proceedings.

The visitors started the day on 100 for three with a lead of 112 runs and Azhar Ali moved to his 14th half-century off 150 balls but he added only 14 runs with his captain Misbah-ul-Haq before South Africa got the breakthrough.

Misbah initially looked uncomfortable against the movement that Vernon Philander was getting, but it was spinner Robin Peterson who accounted for his dismissal. Just an over after the South Africans wasted a review for a catch at slip after a reverse sweep went wrong, the conventional sweep proved to be Misbah's downfall as it looped to Graeme Smith at short fine leg.

Once the South African bowlers got a sniff, they chipped away at the wickets with Asad Shafiq (19) next to go in rather unfortunate circumstances. After confidently playing a defensive shot, the ball spun back towards the stumps, dislodging the bail on off-stump.

It was a bit of a procession after that as Sarfraz Ahmed, Ali and Gul departed in the space of three balls. Wicketkeeper Ahmed opted to shoulder arms a ball to Peterson, but it spun into his stumps.

Ali's resistance was ended as edged a good delivery from Philander (four for 40) to AB de Villiers while Gul went the very next ball for a pair after he chased a wide one and was brilliantly caught by Petersen in gully.

Ajmal and Tanvir Ahmed went to lunch at 157 for eight and the visitors added only another 12 runs before they were all out for 169 with the former becoming Peterson's third victim and Mohammad Irfan caught at third slip off Steyn's bowling.

The two teams now move on to Pretoria for the third and final Test at SuperSport Park which gets underway on Friday.