Pakistan's pace-cum-spin attack caught world No1 test team South Africa napping on the third day of the first test in Abu Dhabi.
South Africa lost four top-order batsmen against a spirited Pakistan and now need another 121 runs to avoid an innings defeat at Sheikh Zayed Stadium and concede the lead in the two-test series.
AB de Villiers was unbeaten on 11 and with him nightwatchman Dale Steyn on nought on a day when Pakistan captain Misbah-ul Haq scored his fourth test hundred and then sent his rivals into submission.
Pakistan removed Alviro Petersen (17), Graeme Smith (32) and Jacques Kallis (nought) by the 19th over and then first innings centurion Hashim Amla for 10 to move closer to a big victory when bad light curtailed play seven overs early.
Paceman Mohammad Irfan struck in his sixth over when a rising delivery caught Petersen by surprise, Adnan Akmal holding the catch cleanly.
Smith looked confident during his 61-ball knock but missed one delivery from Saeed Ajmal and was stumped on the second attempt by Akmal, leaving South Africa at 57-2.
A run later Kallis was trapped in front of the wicket by fast bowler Junaid Khan for a duck. Amal fell caught behind off Zulfiqar Babar's first delivery in the innings to leave South Africa tottering at 72-4.