Bad light stopped them one wicket from victory, but Australia will win the Test on the fifth day at Kingsmead. However, South Africa found a new hero as Aiden Markram created genuine hope from what had seemed a hopeless cause. Set 417 to win, which would have been the second-highest successful chase in Test history, South Africa first collapsed to 49 for 4, and a quick finish seemed all but assured. Instead, Markram fought, counter-attacked, and together with Quinton de Kock took South Africa to within 134 of their target with five wickets in hand. And then it all fell apart.

Mitchell Marsh, who had not taken a Test wicket since November 2016, made the breakthrough when Markram tried to glide him past Tim Paine, only to have his thin edge brilliantly snapped up by the wicketkeeper. Thus ended a 147-run partnership between Markram and de Kock, and Australia sensed the chance to run through the tail. Mitchell Starc did just that. He had Vernon Philander caught behind, before his pace and accuracy rattled the stumps of Keshav Maharaj and Kagiso Rabada for ducks from consecutive deliveries.

But Starc was denied the chance to push for his hat-trick, for the Rabada wicket came from the final ball of an over, and in the meantime the light had deteriorated such that the umpires would only keep the players on the field if Australia bowled spin from both ends. Nathan Lyon and Steven Smith bowled in tandem for nine overs but could not find the final wicket Australia needed, and when the umpires finally decided the light was insufficient even for spin bowling, South Africa were 293 for 9, with de Kock on 81, Morne Morkel yet to score, and their nominal target still 124 runs away.

Aiden Markram battled for 171 balls to score his third Test hundred AFP

For Australia, it was a shame the result could not be finalised before stumps. For South Africa, it was a shame that all the hard work put in by Markram and de Kock would come to nothing. And for the coffers of Cricket South Africa, it was a shame they would have to fork out to open the stadium on the fifth day for what could be as little as one ball. Perhaps only one man will be truly happy to come back - Starc, who at length will get the opportunity to bowl for his hat-trick.

The morning had started with Australia on 213 for 9 and the last pair, Josh Hazlewood and Pat Cummins, added 14 before Cummins chopped on to give Maharaj his ninth wicket of the match. The target of 417 was thus confirmed, just one run short of the all-time highest successful chase in Test history, the 418 achieved by West Indies against Australia in Antigua in 2003. More relevant to South Africa, given that AB de Villiers and Hashim Amla played key roles in it, was the 414 South Africa had chased down to beat Australia in Perth in 2008.

But with every early wicket - and there were a lot of them - South Africa's chances of pulling off another miracle dwindled. Dean Elgar was caught behind off Starc for 9, Amla was lbw to Hazlewood for 8, and Faf du Plessis was bowled through the gate by Cummins for 4. In the meantime came the wicket that rather summed up South Africa's struggle, when Markram pushed Lyon to square leg and took a couple of steps before sending back AB de Villiers, who had over-committed and was comprehensively run out for a duck at the non-striker's end.

But all along, Markram looked solid. He found allies, first Theunis de Bruyn in an 87-run partnership, and then de Kock. De Bruyn drove well and frustrated the Australians such that Starc was expending just as much energy on his verbal barrage to de Bruyn as he was his bowling. At one point, Starc was so mouthy that he risked missing the next Test through laryngitis, but de Bruyn eventually fell for 36 to a thin edge behind off Hazlewood.

Meanwhile, Markram just kept batting. Fittingly for a man whose surname is a palindrome, the results were the same whether Markram played forward or back. He drove handsomely through the covers off front and back foot, and scored runs all around the ground, striking 19 fours on the way to the third century of his short Test career. And, not to disparage the Bangladesh and Zimbabwe oppositions he scored the first two against, this was clearly the innings that will make his name as a Test cricketer.

He brought up his century from his 171st delivery with a very risky single pushed to mid-on - a direct hit would have had him run out for 99 - and he went on to finish with 143, the highest fourth-innings score by any batsman in a Test in South Africa since 1995, when Mike Atherton's unbeaten 185 helped England play out a draw at the Wanderers. Barring a day of heavy rain, which has not been forecast, there will be no such result this time for Markram.

The importance of de Kock's innings should not be forgotten, either. He walked to the crease having not passed fifty in his previous 15 Test innings, but played his natural game and took the attack up to the Australians. His partnership with Markram rattled along at more than four runs an over, and his half-century came from 68 deliveries. De Kock struck 11 fours, but trudged off in the evening gloom knowing that a century was only marginally more likely than South Africa avoiding defeat.