SOUTH Africa is in the box seat to square the series in Port Elizabeth after Usman Khawaja's fighting knock fell over at the final hurdle.
Australia find themselves in a world of hurt just 41 runs ahead with only five wickets in hand to mount a challenging total for South Africa to chase.
Kagiso Rabada was again the chief destroyer for the Proteas as he banished David Warner and Shaun Marsh before coming back from an exhausting afternoon in the field to trap Khawaja lbw for 75 just seven minutes from stumps.
Rabada's devastating impact is a double-edged sword for South Africa who are likely to lose their spearhead to suspension for the rest of the series.
Proteas master AB de Villiers (126 not out) put Australia to the sword with one of the great Test hundreds, before South Africa racked up four quick wickets and were at one point a chance of powering to an emphatic innings victory inside three days.
Khawaja turned the tables on his poor overseas record to rescue Australia from embarrassment, but after 255 minutes of hard work and determination, the left-hander was caught plumb in front just seven agonising minutes from stumps to leave his side precariously placed at 5-180 following a first innings deficit of 139.
Mitchell Marsh (39 not out) batted beautifully in an 87-run partnership with Khawaja, and the in-form all-rounder must play the innings of his life to give Australia any chance of forcing a thrilling finish.
Proteas tailenders Vernon Philander and Keshav Maharaj put on 140 runs between them with de Villiers at the death - and Australia need something similar from the likes of Pat Cummins and Mitchell Starc.
Australian assistant coach David Saker believes there's a glimmer of hope for his side if they can get to a lead of 150 plus but conceded losing Khawaja on the bell was a bitter blow.
"We've had a bit of a habit of losing wickets just before breaks which has hurt us throughout the series so far," said Saker.
"He batted superbly throughout the day so to lose him so late was obviously disappointing. We'll just have to regroup and hopefully Tim (Paine) and Mitch can put on another 50 or 60 and get us to a decent lead.
"Our tail have been very good this series, so we're still confident we can get a total that can be defended.
"The longer we bat out there the more wear there will be on the wicket. There are some tricks coming out of those footmarks already, so 150-plus lead will be a very tough ask for the opposition.
"We're not sure how hard it will be in the morning, but if the ball is reversing like it was this morning and late today, we get through the first five or six overs and see where we're at."
Khawaja was under enormous pressure coming out to bat given he averaged just 24.59 from 13 Test matches overseas.
With a tour of the UAE against Pakistan coming up later in the year, Khawaja needed to stand up in South Africa to be any chance.
Khawaja didn't go on with the job but his 75 off 136 balls showed that he is a world class batsman.
Against torrid reverse swing from Rabada and company and with wickets falling around him, Khawaja survived some tough periods where he looked all at sea to eventually get on top and stamp his authority.
The half century isn't enough to completely silence his critics, but Khawaja can now take confidence into the final Tests in Cape Town and Johannesburg.
Australia was in massive trouble at 4-86, before Khawaja and Marsh dug in to get them at least to a lead.
David Warner copped a stunning delivery from Rabada and then a send-off for his troubles - as the fiery South African quick pushed the limits of another demerit point.
Cameron Bancroft fell cheaply when he played on, and then Steve Smith nicked a superb delivery from spinner Keshav Maharaj.
Saker described Rabada as a freak of nature.
"He's a great product. Even two or three years ago when I first saw the guy, it was pretty exciting," said Saker.
"He's still a kid now, he's just got this raw pace, his arm speed is quite amazing and he keeps running in.
"Like a lot of really good bowlers he gets wickets in clumps and puts pressure on the new batters.
"He's hard to start against because of his pace. You wouldn't be changing a thing. South Africa are very blessed to have him in their team."
After resuming day three only 20 runs ahead and with three wickets in hand, South Africa's tail led by de Villiers took the match away from Australia.
Not to be outdone by de Villiers Maharaj (30 off 24) opened the shoulders and took advantage of a tiring Australian attack.
Maharaj was nearly caught out on the fence by Usman Khawaja, at the very start of his innings only for the Australian to touch his foot down outside the rope as he attempted to throw the ball back into play.
It would prove a huge turning point.
The tailender didn't look back from that point and piloted Lyon for another two sixes as well as three consecutive fours off Starc.
Stumps on Day 3 of the second test between South Africa and Australia at St. George's Park:
Australia First Innings: 243
South Africa First Innings:
Dean Elgar c Paine b Hazlewood 57
Aiden Markram lbw b Cummins 11
Kagiso Rabada b Cummins 29
Hashim Amla b Starc 56
AB de Villiers not out 126
Faf du Plessis lbw b Marsh 9
Theunis de Bruyn lbw b Marsh 1
Quinton de Kock b Lyon 9
Vernon Philander c Bancroft b Cummins 36
Keshav Maharaj b Cummins 30
Lungi Ngidi run out (Smith) 5
Extras: (9b, 2lb, 2w) 13
TOTAL: (all out) 382
Fall of wickets: 1-22, 2-67, 3-155, 4-155, 5-179, 6-183, 7-227, 8-311, 9-369, 10-382.
Bowling: Mitchell Starc 33.4-5-110-1, Josh Hazlewood 30-5-98-2, Pat Cummins 24-6-79-3 (2w), Nathan Lyon 22-5-58-1, Mitchell Marsh 9-1-26-2.
Australia Second Innings
Cameron Bancroft b Ngidi 24
David Warner b Rabada 13
Usman Khawaja lbw b Rabada 75
Steve Smith c de Kock b Maharaj 11
Shaun Marsh c de Kock b Rabada 1
Mitchell Marsh not out 39
Tim Paine not out 5
Extras: (10lb, 2w) 12
TOTAL: (for 5 wickets) 180
Still to bat: Pat Cummins, Mitchell Starc, Nathan Lyon, Josh Hazlewood.
Fall of wickets: 1-27, 2-62, 3-77, 4-86, 5-173.
Bowling: Vernon Philander 14-5-38-0, Kagiso Rabada 16-7-38-3 (1w), Keshav Maharaj 20-2-70-1, Lungi Ngidi 10-4-21-1, Aiden Markram 3-1-3-0.< Toss: Australia.
Series: Australia leads four-test series 1-0.
Umpires: Chris Gaffaney, New Zealand, and Kumar Dharmasena, Sri Lanka. TV umpire: Sundaram Ravi, India. Match referee: Jeff Crowe, New Zealand.
Update your news preferences and get the latest news delivered to your inbox.