South Africa are staring at defeat as they finished day four of the first Test against Australia at Kingsmead on 293-9.
Aiden Markram and Quinton de Kock had put on 147 for the sixth wicket and gave the Proteas a fighting chance of pulling off an unlikely victory.
When Markram was eventually dismissed for 143, the Australians were back in charge, and Mitchell Starc produced the over of the match when he picked up three wickets for no runs as he rattled the South African lower order. De Kock and Morne Morkel saw South Africa to the end of play.
Australia need just one wicket to wrap up the Test.
The third session began well for South Africa as Markram and De Kock built their innings following the dismissal of Theunis de Bruyn.
The South African resistance gathered momentum, and the partnership between Markram and De Kock was worth 50 runs.
De Kock smashed Josh Hazlewood for two fours, and Markram followed suit when he sent Starc to the boundary.
Markram brought up his third Test hundred with a risky single through mid-on and received a deserved standing ovation from the spectators.
Having been involved in running AB de Villiers out in the first session, the century was a massive moment for young Markram.
De Kock got his 12th Test fifty with the following ball when he hit Starc for four.
The two started playing with a bit more freedom after reaching their milestones as the fightback started to gather some momentum.
Australia were convinced they had taken the wicket of Markram, but a review showed that the South African batsman was hit on the helmet.
A short ball from Pat Cummins hit Markram on the arm, but the 23-year-old was soon back on his feet.
Markram, who had been driving well all day, brought up the 100-run partnership between himself and De Kock with a four through cover.
De Kock and Markram were scoring at more or less five runs an over after tea.
But Markram was finally out for a well played 143 after a faint outside edge off the bowling of Mitchell Marsh. The South African dressing room and the spectators rose to their feet as Markram walked off the park.
Once the wicket of Markram was lost, Starc cleaned up the South African tail, picking up the wickets of Vernon Philander (6), Keshav Maharaj (0) and Kagiso Rabada (0).
With the light fading fast, the umpires were keen to walk off the field, but play was allowed to continue until 18:00.
Australia (1st innings) 351: Mitchell Marsh 96, Steve Smith 56; Keshav Maharaj 5-123, Vernon Philander 2-59
South Africa (1st innings) 162: AB de Villiers71, Aiden Markram 32; Mitchell Starc 5-34, Nathan Lyon 3-50
Australia (2nd innings) 227: Cameron Bancroft 53, Steve Smith 38, Keshav Maharaj 4-102, Morne Morkel 3-42
South Africa (2nd innings) 293-9: Aiden Markram 143, Quinton de Kock 81*, Mitchell Starc 4-74, Josh Hazlewood 2-57
South Africa need 124 to win
Photo: Lee Warren/Gallo Images