Pakistan, resuming at 145-3, were bowled out for 272 in their first innings in the second Test against South Africa at Rawalpindi Cricket Stadium on Friday.
Pakistan lost overnight batsman Babar Azam off the second ball of the day, without adding to his 77, while Fawad Alam scored another three before falling for 45.
Faheem Ashraf scored a brilliant 78 not out.
Fast bowler Anrich Nortje took 5-56 while Keshav Maharaj finished with 3-90.
Azam slashed at a short delivery from paceman Nortje and was smartly snapped head high by Faf du Plessis in the second slip for his overnight score of 77.
At lunch, Ashraf was on a gritty 54 and Yasir Shah yet to score with Pakistan adding 84 in an extended session due to Friday prayers.
Azam’s dismissal was the start of a mini-collapse which saw Pakistan lose two wickets in the space of 34 balls with the addition of just four runs after resuming at 145-3.
The other overnight batsman, Alam, was run out after he tried to steal a quick single with a push to cover but failed to beat a direct throw from Temba Bavuma at the non-striker’s end.
Alam could only add three to his overnight score of 42.
Azam, who was looking set for his sixth Test century, had hit 12 boundaries off 127 balls.
Ashraf then added 41 with Mohammad Rizwan but once South Africa took the second new ball Nortje struck again, having Rizwan caught off a miscued hook for 18.
Left-arm spinner Keshav Maharaj had Hasan Ali for eight. Nortje (3-48) and Maharaj (3-75) were the pick of the South African bowlers.
Pakistan lead the two-match series 1-0 after beating the Proteas in the first Test by seven wickets at Karachi last week.