Two Matt Toomua penalties after the break added to the centre's first-half try and one from his captain Michael Hooper to give the Wallabies their first win in five matches after back-to-back losses to Ireland and New Zealand.
"It was tight," said Hooper, who led a side without late withdrawals David Pocock, Israel Folau and Adam Coleman.
Aaron Smith's toilet tryst overshadows All Blacks squad
"We knew it would be that way. We knew they would come out firing. It was a good game, back and forth a lot. I'm really proud of the guys' resilience."
Tries from hooker Bongi Mbonambi and winger Makazole Mapimpi helped to give South Africa an 18-17 lead at halftime but they were held scoreless after the break to slump to a second successive defeat after a loss to Argentina last time out.
"We made it tough for ourselves by not taking our opportunities again," said skipper Siya Kolisi.
"Australia played really well and they took their opportunities. At this level you have to take the opportunities when you get them."
Hooker Bongi Mbonambi and winger Makazole Mapimpi had helped to give South Africa an 18-17 lead at the break but they were held scoreless in the second half to slump to a second successive defeat after a loss to Argentina last time out.
The Springboks pressed hard for what would have been a match-winning try over the final few minutes but the home side held them off with a huge defensive effort.
Elsewhere, scrumhalf TJ Perenara scored a try in each half as the All Blacks were pushed all the way by Argentina before they pulled away with two late tries in a 46-24 Rugby Championship triumph at Trafalgar Park in Nelson on Saturday.
Perenara, who was given a rare start, also made a try-saving tackle on Matias Moroni and cleared up a loose ball in the goal area as the home side were regularly put under intense pressure from the Pumas.
Winger Nehe Milner-Skudder, captain Kieran Read, Shannon Frizell and Jack Goodhue also scored tries for the All Blacks, who suffered injuries to lock Brodie Retallick (arm) and inside centre Ngani Laumape (knee) early in the game.
Flyhalf Nicolas Sanchez scored a try and ended with 14 points to reach 655 in his career and surpass Felipe Contepomi as his country's highest test scorer, while winger Ramiro Moyano and fullback Emiliano Boffelli also crossed for tries.
All Blacks set for wholesale changes against Springboks
Australia strike early to down Argentina in Perth
Share this article