Markram, dismissed for a duck in the first innings, was 102 not out and Bavuma unbeaten on 65 despite spending most of his innings limping with a hamstring injury.
But South Africa have such a long history of folding under pressure that they could not take anything for granted against Australia, the serial winners and defending World Test Championship (WTC) title-holders.
In 18 previous attempts in the one-day international and Twenty20 World Cups, South Africa had only reached a solitary final.
That was in last year’s T20 World Cup in Barbados, when they lost to India – despite needing just 30 runs from their last 30 balls, with six wickets standing.
But South Africa, so often labelled “chokers” for their failure to close out knockout games, held their nerve as a largely unheralded side succeeded where star players such as Allan Donald, Shaun Pollock, A.B. de Villiers and Jacques Kallis had failed.
South Africa’s path to the final was criticised, with the Proteas playing just 12 tests in the WTC cycle and none against England or Australia.
But with Australia strong favourites to retain their title, South Africa posted an eighth successive test win in impressive style.
“I hope our performance gives credit as to why we were in the final,” said Bavuma.
“Whilst we were batting, we could hear the Aussies using that dreaded word ‘choke’. We’ve been etched in history, we’re part of something that has never been done.”
The celebrations spread across the Lord’s turf as each of the players took their turn with the silver-and-gold mace.
“It is emotional, it’s been a very long time coming,” said Markram, who was named player of the match.
“We’ve got close in the past couple of years and not got over the line. The first one is always going to be the toughest.”
Australia led by 74 runs after the first innings but never got completely away from South Africa, with Proteas fast bowler Kagiso Rabada returning superb match figures of 9/110.
“Unfortunately, it was a bridge too far,” said Australia captain Pat Cummins, who led his side to the 2023 WTC title after New Zealand won the inaugural 2021 final.
“They [South Africa] were fantastic in that fourth innings. There wasn’t a lot in the wicket but they didn’t give us a chance.”
South Africa suffered a setback when Bavuma, who had added just one run to his overnight score, was caught behind off Cummins to end a stand of 147 with Markram.
But Markram got the target down to 50 by pulling Cummins for four before left-arm quick Mitchell Starc (3/66) bowled Tristan Stubbs.
Australia took the new ball with South Africa needing just 14 more runs to win and Markram subsequently drove Josh Hazlewood for four and three to settle any nerves.
He couldn’t quite finish the job, though. His pull off Hazlewood was brilliantly caught by Travis Head at midwicket to end a 207-ball innings, featuring 14 fours.
As Markram received a standing ovation on his way back to the pavilion, several Australia players shook his hand.
It was left to Kyle Verreynne to hit the winning run as South Africa completed the second-highest chase to win a test at Lord’s, behind the West Indies’ 344/1 against England in 1984.