A stunning triple-wicket maiden from Mitchell Starc has put Australia on the brink of victory after Aiden Markram gave South Africa hope with a brilliant century.
A fighting century from South African youngster Markram stalled Australia's bid for victory in Durban, but the tourists rallied and will resume on day five needing one wicket to win the Test series opener.
'DISRESPECTFUL': Aussies under fire over controversial celebrations
The Proteas, set an intimidating target of 417 on Sunday morning, crashed to 4-49 in their second innings and looked set to suffer an ignominious defeat.
Markram spearheaded a commendable fightback, producing a gutsy knock of 143 in his seventh Test, but fell to Mitch Marsh and the hosts were 9-293 when bad light ended play in absurd fashion.
Marsh, nursing a sore shoulder, and Tim Paine, keeping up to the stumps, combined to end Markram's remarkable resistance that spanned five and a half hours.
Paine snapped the 147-run stand between Markram and Quinton de Kock by holding one of the sharpest - and most important - catches of his career.
Starc followed it up soon after with the scalps of Vernon Philander, Keshav Maharaj and Kagiso Rabada in a triple-wicket maiden that eased Steve Smith's nerves.
The lightmeter, a device used on every day of the contest, then delivered the latest dose of drama on a day when tensions repeatedly frayed.
With the second new ball due and Starc gunning for his 10th wicket in the Test, Smith was told by the umpires he couldn't use any of his quicks.
Starc will be on a hat-trick when he next bowls, having skittled the stumps of Maharaj and Rabada with consecutive deliveries.
De Kock, who will resume on 81, and Morne Morkel survived some nine overs as Smith and Nathan Lyon unsuccessfully attempted to end the final partnership in gloomy conditions.
Smith was locked in deep discussions with umpires throughout the final-wicket stand, but officials Sundaram Ravi and Kumar Dharmasena eventually decided enough was enough with five overs remaining in the day.
Starc is just one wicket away from capping one of his greatest performances in the baggy green with a hat-trick and 10-wicket haul.
He has match figures of 9-108 in Durban, having twice busted the first Test open with a reverse-swing masterclass.
Michael Holding suggested Starc could become the best fast bowler in the world whenever Dale Steyn retires.
"Mitchell Starc, against these lower-order batsmen, I ain't going to blame any of them for getting bowled out like that," Holding told ESPNcricinfo.
Statistically the greatest haul of Starc's Test career is the 11-94 he snared against Sri Lanka in 2016 at Galle but a match-winning effort at Kingsmead against the world's no.2 Test team in a series opener is arguably even more impressive.
"It was good fun, but this bowling unit has confidence in each other and we all complement each other really well," Starc said after grabbing five wickets in South Africa's first innings.
The Proteas had been asked to almost better the Test record run chase of 418.
Such a turnaround would have been a shock in one sense, given how the first 10 sessions of the game unfolded after Smith won the toss.
The rivalry has featured no shortage of incredible finishes, with South Africa's three highest fourth-innings chases all coming against Australia.
It has also featured plenty of spite and verbal stoushes, a trend that David Warner continued on Sunday.
Warner regained his hostile streak amid a chaotic 45 minutes in which Dean Elgar, Hashim Amla, AB de Villiers and captain Faf du Plessis folded in a collapse of 4-20.
A fired-up Warner ran de Villiers out for a duck at the non-striker's end following a calamitous mix-up between the gun batsman and Markram.
Markram was guilty of ball watching and Warner let him know all about it, roaring like a man possessed.