Bavuma produced a brilliant 179 on Tuesday to take the hosts to 9(dec)-425 and leave Australia a difficult 23 minutes to bat at the end of day three at St George's Park.
After being 6-110 at one stage early on Tuesday, the South Africa are now the only team able to realistically push for victory in this rain-affected match.
With most of the opening two days lost, the Proteas still need to bowl Australia out twice in two days to level the series ahead of next week's third Test in Cape Town.
But after Australia began the third day with control of this Test and the series, the hosts at least have a chance thanks to their captain.
The diminutive right-hander came to the wicket at 2-20 on the opening day just before rain stopped play, and helped rescue the Proteas from 4-40 and 6-110.
He did so with the help of the hard-swinging Marco Jansen. The pair put on 132 for the seventh wicket with the Proteas quick hitting 85 himself.
South Africa's highest eighth-wicket stand of 183 followed during which Simon Harmer, previous Test batting average 18.11, made his Test-best 82. With Nathan Lyon not selected Matt Renshaw, Nic Maddinson and Marnus Labuschagne bowled 15 overs of spin.
Bavuma left well and was the Proteas' composed man, after admitting his own decision making was poor in last week's 214-run loss to Australia in Durban.
After getting through difficult periods on the wet opening two days, Bavuma produced some beautiful on-drives off Scott Boland (5-89) and Pat Cummins on Tuesday.
Another crunching cut shot in front of point came off Josh Hazlewood as he approached three figures, before bringing it up pulling Cummins for four.
He offered one tough chance when Steve Smith couldn't grasp a low ball at slips off Hazlewood on 122, before being eventually caught behind off Mitchell Starc to prompt the declaration.
Bavuma has scored five Test centuries, four of them as captain. This one was his highest, and finest given the circumstances.
At the other end, Jansen provided the fireworks in the morning.
He drove Boland for a massive six over mid-off, hit another down the ground off Renshaw that crashed into the commentary boxes and pulled Cummins for a third over square leg.
And when he blew a maiden century when he chipped Boland to midwicket in the first over with the new ball, Harmer arrived to help Bavuma carry on.
The door had looked open for Australia early when Starc (3-89) had Wiaan Mulder caught in the slips with a brute of a ball that took the right-hander's glove and helmet on the way through.
It made Starc the 10th man to claim 450 Test wickets, after Boland had ripped through South Africa across the 43 overs available on the opening two days on the way to his third five-wicket haul.