Pakistan, fighting to save the second and final Test, were 2-2 at lunch on the third day after South Africa piled up 517 on Friday in Dubai.
Pakistan trail by 416 runs after conceding a huge 418-run lead on the first innings.
They lost opener Shan Masood off the fourth ball for nought to paceman Dale Steyn and, in the next over, Khurram Manzoor was also out for a duck.
Manzoor, who hit 146 in Pakistan’s seven-wicket win in the first Test in Abu Dhabi, ended with a pair for the match.
At the break, Azhar Ali was unbeaten on two after an extended two-and-a-half hour session due to Friday prayers.
That was far from the ideal start Pakistan needed as they were left frustrated by Graeme Smith (234) and AB De Villiers (164) as South Africa took command of the match after bowling Pakistan out for a paltry 99.
South Africa had resumed their first innings on 4-460 but managed to add just 57 more as offspinner Saeed Ajmal wrapped up the innings with 6-151.
De Villiers was the first to go as he slashed at an outgoing delivery and was smartly caught by wicketkeeper Adnan Akmal.
De Villiers hit 17 fours and a six during a commanding 376-minute innings and completed an all-time South African fifth-wicket record partnership of 338 with Smith.
Irfan could have removed Smith in his next over but Akmal again faltered behind the stumps, dropping a shoulder-high catch to his left.
But unlike Akmal’s dropped catch off De Villiers on the very first ball on Thursday, this didn’t prove costly as Smith was caught at slip by Younis Khan in Ajmal’s next over.
Smith’s superb knock lasted 10 hours and 32 minutes during which he dominated Pakistan’s bowling, hitting 16 boundaries and facing 388 balls.
With that catch, Younis beat Javed Miandad’s record of most Test catches of 93. It took him 86 Tests, 38 fewer than his illustrious countryman.
Irfan continued his demolition when he removed Jean-Paul Duminy in his next over with a fuller-length delivery for seven.
Pakistan suffered another jolt when Irfan was removed from the bowling attack by Australian umpire Rod Tucker for running into the danger zone after a second warning.
Ajmal removed the tail by dismissing the last three wickets for his ninth five-wicket haul in Tests.
