Pakistan lose openers after Hasan gives them lead in second Test
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.
Azhar Ali was unbeaten on 22 and skipper Babar Azam five not out as Pakistan's overall lead is 113 runs with eight second wicket intact.
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 spinner Keshav 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.
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.
Pakistan 1st innings 272 (Babar Azam 77, Faheem Ashraf 78 not out; A. Nortje 5-56, K. Maharaj 3-90)
South Africa 1st innings (overnight 106-4)
D. Elgar c Rizwan b Hasan 15
A. Markram c Shaheen b Nauman 32
R. van der Dussen b Hasan 0
F. du Plessis c Rizwan b Ashraf 17
T. Bavuma not out 44
Q. de Kock b Shaheen 29
W. Mulder run out 33
G. Linde b Hasan 21
K. Maharaj b Hasan 1
K. Rabada run out 0
A. Nortje b Hasan 0
Extras: (nb9) 9
Total: (65.4 overs; all out) 201
Fall of wickets: 1-26 (Elgar), 2-26 (Dussen), 3-55 (du Plessis), 4-81 (Markram), 5-114 (de Kock), 6-164 (Mulder), 7-186 (Linde), 8-192 (Maharaj), 9-201 (Rabada)
Bowling; Shaheen 13-2-37-1 (nb3), Hasan 15.4-2-54-5 (nb6), Ashraf 8-2-20-1, Nauman 17-8-36-1, Yasir 12-2-54-0
Umpires: Aleem Dar (PAK) and Ahsan Raza (PAK)
TV umpire: Asif Yaqoob (PAK)
Match referee: Mohammad Javed Malik (PAK)