South Africa face a battle to avoid another first-innings deficit after Anrich Nortje's fine work with the ball was undone by a rocky reply to Pakistan's 272 in the second Test.
Pakistan had made 145-3 on day one before rain intervened and Nortje was the cause of their frustration when play resumed on Friday, snaring 5-56 to put the hosts in the field before tea.
But the Proteas' solid early efforts with the bat - including a string of boundaries - were disrupted by Hasan Ali, who removed Dean Elgar (15) and Rassie van der Dussen from consecutive deliveries.
With those wickets right at the end of the second session, the day turned and Faf du Plessis followed to Faheem Ashraf for 17.
Nauman Ali - sublime in the first Test as Pakistan dominated - then teed up a simple but crucial catch for Shaheed Afridi to remove Aiden Markram (32), reducing South Africa to 81-4 before a mini-recovery to 106 without further loss preceded the close of play.
It ended a day of two halves as the Proteas, just like a day earlier, enjoyed a productive first session, with Babar Azam unable to add to his overnight score of 77, edging Nortje to second slip from just the second ball of the day.
Fawad Alam (45), who had held up the other end of a vital partnership on Thursday, swiftly followed, too, run out with a superb direct hit from Temba Bavuma.
Faheem steadied the Pakistan innings slightly, although Nortje's decision to take the second new ball soon paid dividends as he halted Mohammad Rizwan (18) in his next over.
That dismissal ended a promising stand of 41 and Faheem eventually ran out of partners, still unbeaten on 78 as Nortje concluded the innings and his five-for with fierce deliveries to Nauman and Shaheen in the same over.
Only if South Africa can regain some composure with the bat will Nortje be able to celebrate his contribution to a much-needed win, which would be their first in 14 Tests on the subcontinent.
HASAN ALI HAVING HIS SAY
Hasan has endured a tough time with injury in the past few years, returning to the Test arena in this series for the first time since January 2019. If the fast bowler was merely playing a supporting role to the spinners in the opening match last week, this was a more telling contribution, potentially changing the course of the result.
SOUTH AFRICA TURN TO SKIPPER
Quinton de Kock would appear to be taking charge of his final Test match as South Africa captain but may now have to rediscover his best form to make sure it is not a losing swan song. The skipper has not made a Test fifty since January 2020 or a hundred since October 2019, yet the Proteas were reeling as he arrived at the crease on Friday, able to settle the innings a little by dashing to an unbeaten 24 at stumps.