Flyhalf Will Genia celebrated his return from a thumb injury with a 75th-minute try to seal victory after South Africa scored two second-half tries to claw to within 10 points.
Drew Mitchell scored on the stroke of halftime and Matt Giteau slotted five penalties to maintain the Springboks' winless record at Lang Park and leave their Tri-nations campaign on the brink of collapse after three straight losses.
The Springboks did themselves few favours, having a man sin-binned at the start of each half and conceding a raft of first-half penalties to allow the Wallabies to open a 17-3 lead at the break.
Jacque Fourie and Gurthro Steenkamp scored South Africa's first tries in 13 years at Lang Park after an indisciplined first half in which they managed only three points from a Morne Steyn penalty.
(Reporting by Ian Ransom; Editing by Justin Palmer; To query or comment on this story email firstname.lastname@example.org)