Australia came back with five wickets in the final session to stop South Africa's momentum and hold the home team to 263/7 by stumps on Day 2 of the second Test on Saturday, a lead of 20 runs. South Africa were 153/2 at tea, with two batsmen on half-centuries, and heading for a significant first-innings lead at St. George's Park before Mitchell Starc bowled Hashim Amla with a swinging yorker on the fourth ball of the last session to start Australia's comeback.
Amla was out for 56, opener Dean Elgar followed next over for 57, and allrounder Mitchell Marsh picked up two wickets as Australia's bowlers went on a run of four wickets for 28 runs.
AB de Villiers held South Africa together until stumps with 74 not out from just 81 balls, a free-flowing innings with 14 fours that made batting look much easier than it was on a pitch offering heaps of reverse swing.
South Africa are ahead but their position is not as strong as they were hoping for after a strong start. That replicated Australia's first innings, when the tourists were 161/3 and 243 all out in a similar late slump.
Even though Elgar and Amla put on 88 for South Africa for the third wicket, that stand took nearly three and a half hours and 278 balls, with batting a grind in the afternoon.
Amla was twice given out lbw by the onfield umpires and twice overturned the decision using the TV review system, surviving first when he was on 7 and again when on 40.
South Africa lost just one wicket in the first session, nightwatchman Kagiso Rabada for 29, and no wickets in the second session, before the late surge from the Aussie quicks.
Starc bowled Amla and Josh Hazlewood had Elgar caught behind eight balls later. Marsh trapped South Africa captain Faf du Plessis and Theunis de Bruyn lbw in successive overs.
Rabada was the chief destroyer in the Australian first innings with 5/96, including a burst of 5/13 off 18 balls.
But after another incident that undermined the cricket, Rabada's participation in the remainder of the series is in doubt.
He was charged on Saturday morning by match officials for misconduct after bumping into Australia captain Steve Smith with his shoulder when he dismissed Smith on the first day.
Rabada faces a two-test ban if found guilty of deliberately making physical contact with Smith, which would see South Africa's best fast bowler miss the last two Tests of the series. Rabada will have a disciplinary hearing in Port Elizabeth on Sunday, the South African team said. He is claiming the contact with Smith was unintentional.
Rabada's is the fourth player disciplinary case of a spiteful series so far after Australia's Nathan Lyon and David Warner and South Africa's Quinton de Kock were all found guilty of bringing the game into disrepute in the first Test in Durban.
Australia won in Durban by 118 runs to lead the four-Test series 1-0.