Pakistan extended overall lead of 200 and four wickets intact on a tacky Rawalpindi stadium pitch, which has cracks to help slow bowlers.
Allrounder Faheem Ashraf and Mohammad Rizwan were dropped off successive deliveries before featuring in a 52-run sixth-wicket stand which guided the home team to 129-6 in the second innings at stumps.
Pakistan had earlier dismissed the Proteas for 201 in 65.4 overs and gained a 71-run first innings lead. Hasan Ali took five wickets for 54 runs. The Babar Azam-led side had scored 272 in the first innings.
George Linde took three wickets and Keshav Maharaj two as South Africa and Pakistan wrestled for advantage on the third day of their second Test in Rawalpindi on Saturday.
Hasan Ali is congratulated teammates, who took five wickets. AP
Linde (3-12) and Maharaj (2-74) rattled Pakistan's top order before Faheem Ashraf (29) and Mohammad Rizwan (28 not out) saved Pakistan's blushes during their 52-run sixth wicket stand.
Linde removed Ashraf caught in covers, leaving Hasan Ali not out on nought when bad light ended the game. The day could have ended in South Africa's domination had Ashraf and Rizwan not been dropped off the two spinners.
Ashraf was yet to get off the mark when Dean Elgar grassed an edge off Linde in slips while Rizwan was four when Rassie van der Dussen let off a sharp chance off Maharaj. Pakistan would hope another 50 runs on day four could win them the match and the series, having won the first Test in Karachi by seven wickets.
READ MORE
England need 600-700 vs India to be in driver seat: Ton-up Root
Pakistan in command despite Nortje five-fer in second Test
Bulls win to set up first qualifier against Warriors; Team Abu Dhabi to clash with Qalandars
Gayle credits Sangakkaras advice for whirlwind knock
Hasan said batting wouldn't be simple given the conditions. "Even chasing 200 won't be easy on this pitch," he said. "We will try to get to 240 to 250 and with our spinners it won't be easy."
The highest target chased in the previous ten Tests at this venue is 220, which Sri Lanka chased to beat Pakistan by two wickets in 2000.
Linde said South Africa were "hungry to win."
"Obviously we have to win this Test to level the series," he explained. "I think anything under 300, we will take that for a chase."
Umpire Aleem Dar discusses with Ahsan Raza (C) regarding light condition at the Pindi Stadium. AP
Earlier, Hasan's 5-54 — his second five wicket haul in Tests — restricted South Africa's first innings to 201, giving the home team a lead of 71.
Pakistan had made 272 in their first innings, but South Africa reduced them to 42-2 by tea.
Pakistan lost newcomer Imran Butt — managing just 36 in four innings of his first series — in the fifth over, leg-before to pacer Kagiso Rabada for duck.
Butt's partner, Abid Ali fell caught behind off Maharaj for 13, ending up with 33 in the series to highlight Pakistan's top order woes. Azhar, on 11, survived a confident leg-before appeal off Maharaj only to see the referral showed it was the umpire's call.
It was Hasan who wrapped up South African innings after they added 95 runs in the morning. Temba Bavuma fought a lone battle with 44 not out.
George Linde bowls next to Mohammad Rizwan. AFP
Resuming at 106-4 South Africa had hoped their skipper Quinton de Kock would build on his breezy overnight score of 24, but the left-hander played on to Shaheen in the third over of the day. De Kock scored 29.
Bavuma and Wiaan Mulder frustrated Pakistan's pace-cum-spin attack during a 50-run sixth wicket stand before disaster struck. Mulder nudged a push to deep fine-leg but while returning for a second run failed to beat a Shaheen throw and was run out.
George Linde hit three boundaries and a six in his quickfire 21 but missed the line of a Hasan delivery and was bowled. Hasan also had Maharaj (one) and Anrich Nortje (nought) to finish the innings.