South Africa lost skipper Faf du Plessis amid a clatter of late wickets as the match pendulum swung decisively towards Australia in the third day-night Test in Adelaide on Saturday.
The Australians, who led by 124 runs on the first innings, reduced the Proteas to 194 for six with the prized wicket of du Plessis for 12 coming late on the third day.
At the close, South Africa were holding on and just 70 runs ahead of Australia heading into Sunday's fourth day.
Opener Stephen Cook was in sight of his second Test century and was unbeaten on 81 off 199 balls with Quinton de Kock yet to score.
Australia, bidding to prevent South Africa from carrying off a series clean sweep after huge defeats in the opening two Tests, took major strides on Saturday with Usman Khawaja leading the way with his near eight-hour epic.
Mitchell Starc captured the big wicket of du Plessis who, motivated by the events of his controversial pre-Test ball-tampering case, scored a career pinnacle unbeaten 118 in the first innings of the match.
Du Plessis attempted to drive Starc only to get an outside edge to newcomer Peter Handscomb, who took a brilliant diving two-handed catch in the gully.
It was a major moment in the course of the Test given the ability of du Plessis to play out long match-saving innings, memorably his defiant 376-ball unbeaten knock of 110 to deny Australia victory in Adelaide four years ago.
Starc started the ball rolling, removing Dean Elgar with the fourth ball of his opening over for a duck and fellow paceman Josh Hazlewood had Hashim Amla caught behind for 45.
It was the fifth time Hazlewood had captured Amla's wicket in five innings in the series.
- Epic knocks -
Spinner Nathan Lyon tightened the screws with three late wickets.
JP Duminy played across the spinner and was bowled for 26 and Temba Bavuma fell three overs from stumps, caught off his gloves by Steve Smith sweeping Lyon for 21.
Lyon removed nightwatchman Kyle Abbott leg before wicket for a duck in the day's final over.
"It was an unbelievable atmosphere towards the end," Lyon said.
"This Test match we have bowled a lot better in partnerships...We still need four wickets and there's still two quality batters there at the moment."
South Africa's chances of posting a competitive lead hinge on Cook and de Kock producing a big stand.
"There is an opportunity for us tomorrow to try and capitalise on a big partnership to try and push us up past 180-200 lead," team batting coach Neil McKenzie said.
"If we can do that and take a few early wickets as we have done to Australia before that will give South Africa a lot of confidence."
Khawaja earlier top scored with 145 with the last four wickets adding 100 runs to put the home side in command.
His 308-ball vigil finally came to an end when he was trapped leg before wicket by Vernon Philander.
The unflappable left-hander occupied the crease for 466 minutes after he was forced to open the innings after a miscalculation over David Warner's time off the field for injury treatment when the Proteas unexpectedly declared.
Khawaja left the field to a standing ovation following his second-highest Test score, amassed over three days, ranking only below his 174 against New Zealand in Brisbane last year.
It was the Pakistan-born batsman's fifth Test century, all posted over the last 12 months.
Khawaja's epic knock was also the first century by an Australian in the South Africa series and he has now scored 314 runs at 62.80 in five innings.
Starc clubbed his seventh Test half-century with a 91-ball 53 before he was caught and bowled by Kagiso Rabada, ending a lively knock that featured five fours and a six.
Abbott was the best of South Africa's bowlers with an economical three wickets for 49 off 29 overs with young gun speedster Rabada claiming three for 84.