Anrich Nortje secured a rare subcontinent five-wicket haul as the Proteas dismissed Pakistan for 272 in Rawalpindi.
Nortje led a resurgent bowling attack from the start of day two with the Proteas fighting back with the ball.
Wiaan Mulder and Nortje picked up the final three Pakistan wickets, dismissing Yasir Shah, Nauman Ali and Shaheen Afridi.
Nortje ended the hosts’ innings with his fifth scalp, claiming figures of 5-56 in 24.3 overs, while Faheem Ashraf finished unbeaten for Pakistan on 78.
Dean Elgar and Aiden Markram made another composed start with the bat but the Proteas were rocked in the final over before the tea break.
Hasan Ali bagged two wickets with consecutive deliveries, removing Elgar, caught behind for 15 before knocking over Rassie van der Dussen for a golden duck.
The Proteas will begin the final session on 26-2 with Aiden Markram unbeaten on ten.
Despite being in control of proceedings the Proteas batsmen will need to stand firm in the final session to avoid a similar batting collapse to the first Test.