Amir dismissed overnight batsmen Quinton de Kock for 59 after he added just four runs to his overnight score of 55. He next sent Vernon Philander packing for 16 followed by Kagiso Rabada for 11.
Shaheen Shah Afridi picked his fourth wicket of the second Test by dismissing Dale Steyn after he smashed 13 off 10 balls.
South Africa have a lead of 254 runs.
South Africa resumed batting on 382-6 on day three of the second Test with a lead of 205 runs and four wickets in hand after captain Faf du Plessis led from the front with a hard-earned century to give the hosts a commanding 205-run advantage at the end of the second day of the second Test.
Du Plessis failed to score in either innings in the first Test in Pretoria last week but made 103 in a 226-ball knock as South Africa piled up 382 for six in reply to Pakistan’s 177 all out on opening day.
Du Plessis had to toil for his ninth Test century on an uneven pitch, hitting some superb shots through extra cover but also surviving being dropped on 96 to an easy catch down leg that Pakistan wicketkeeper Sarfraz Ahmed spilt.
He was eventually out to a feint tickle off teenager Shaheen Shah, who finished the day with the best Pakistan figures of 3-112.
Demba Bavuma, who saw two reviews go his way, made 75 and it was his 156-run fifth wicket partnership with the skipper that enabled South Africa to take the game away from their opponents after losing two wickets early in the day.
“It was a challenging wicket but we tried to be as positive out there as we could be,” Bavuma said.
“Any kind of lead on this wicket is massive.
Our bowlers will be raring to go and looking to exploit it.”
South Africa were on 123-2 overnight but Hashim Amla (24) and Theunis de Bruyn (13) departed in the morning session before Bavuma, having scored three, was reprieved by the third umpire after appearing to be caught in the slips.
It was decided that the catch had been taken off the turf.
He also survived an lbw decision with the review going his way to the exasperation of Pakistan.
Bavuma was eventually caught by Sarfraz off Shaheen, who then also bagged du Plessis but only after another review, which this time went Pakistan’s way.
De Kock hit fours off his first two deliveries and never looked back as he raced to his half-century off 59 balls.