Saeed Ajmal did the damage as Pakistan took the upper hand in the second Test against South Africa in Cape Town.
Ajmal made an unbeaten 21 as Pakistan were bowled out for 338, and struck with an impressive 5-41 as South Africa slumped to 5-139 in reply.
Pakistan, resuming at 5-253, were rocked by the early pace of Vernon Philander, who claimed three wickets in his first three overs.
Asad Shafiq was caught at slip for 111 off the first ball of the day, while Sarfraz Ahmed (13) was out in the same fashion two overs later.
Umar Gul was out lbw without making a run, putting the hosts in a commanding position until Ajmal combined with Tanvir Ahmed for a valuable ninth-wicket stand of 64.
Specialist spinner Robin Peterson claimed the final wickets of Tanvir (44) and debutant Mohammad Irfan (six), but not before Pakistan posted their highest total in South Africa.
Philander finished with figures of 5-59, while Peterson and Morne Morkel took two apiece and Dale Steyn added 1-55.
Ajmal was handed the ball in the 12th over and made the breakthrough in his second over after getting Graeme Smith (19) lbw on review.
Alviro Petersen followed for 17 when Azhar Ali took a sharp catch, before Hashim Amla (25) was trapped lbw, also on review.
Jacques Kallis was dismissed for two following a controversial review that is likely to come under further scrutiny.
Kallis appeared to be given out caught by on-field umpire Steve Davis, though third umpire Billy Bowden ruled him out lbw after replays showed bat and ball didn't contact one another.
However, the final ruling of the review deemed it to be 'umpire's call' on whether it was going on to hit the stumps, and Kallis was sent packing despite Davis' finger being raised for the appeal for a catch.
Faf du Plessis was the next to fall for 28, caught by Younis Khan at slip as Ajmal continued to wreak havoc.AB de Villiers (24) and Dean Elgar (11) were left at the crease with South Africa looking to reverse their fortunes on day three.