A brace of Bryan Habana tries took South Africa to their first win on Australian soil since 1998 in a classic Tri-Nations match in Perth.
Australia 19 (6)
Pens: Giteau 1, Rogers 3
South Africa 22 (14)
Tries: Habana 2
Drop goals: Montgomery
Pens: Montgomery 3
The Wallabies held the lead with 15 minutes to go, but Habana's second breakaway try stole victory.
The Springboks now top the Tri-Nations table and can seal the title if they beat New Zealand in Dunedin next week.
Injury-hit Australia, bottom of the table, have now lost four matches in a row for the first time in 24 years.
With South Africa dominating the scrum throughout the first half, Australia were up against it at half time.
When Percy Montgomery landed a 40-metre drop goal to stretch the lead to 17-9 with half an hour to play, they looked dead and buried.
But, roared on by a capacity 43,000 crowd at the Subiaco Oval, the Wallabies fought back magnificently.
Morgan Turinui broke the tackle of Andre Pretorius 30m out, drew the covering tackle and fed Clyde Rathbone for the try.
Montgomery hit the crossbar of the posts with another penalty attempt before Mat Rogers landed a penalty of his own to put the Wallabies ahead for the first time.
Australia laid siege to the Springbok line and almost broke through before Habana produced his second sensational pitch-length sprint of the match to snatch the lead back.
He had earlier given South Africa the best possible start with just three minutes on the clock.
When Phil Waugh lost the ball 10m from the South African line, Schalk Burger and Jaque Fourie spotted the overlap out wide and fed Habana, who went the length of the pitch to touch down.
But Habana missed a far easier chance with half an hour gone when he spilt a pass with the Australian line at his mercy.
Australia were rocked just before kick-off when fly-half Elton Flatley was ruled out after complaining of double vision.
Mark Gerrard, Stirling Mortlock and Chris Latham were all sidelined earlier in the week.
The Springboks named the same 22 players that beat New Zealand 22-16 in Cape Town two weeks ago.
It was the first time they had used the same 22 for consecutive Tests since the 1999 World Cup.
Australia: Drew Mitchell, Mat Rogers, Clyde Rathbone, Morgan Turinui, Lote Tuqiri, Matt Giteau, George Gregan, David Lyons, Phil Waugh, Rocky Elsom, Nathan Sharpe, Daniel Vickerman, Al Baxter, Brendan Cannon, Bill Young
Replacements: Stephen Moore, Matt Dunning, Mark Chisholm, George Smith, John Roe, Chris Whitaker, Adam Ashley-Cooper
South Africa: Percy Montgomery, Breyton Paulse, Jaque Fourie, Jean De Villiers, Bryan Habana, Andre Pretorius, Enrico Januarie, Joe Van Niekerk, Juan Smith, Schalk Burger, Victor Matfield, Bakkies Botha, CJ Van Der Linde, John Smit, Os du Randt
Replacements: Hanyani Shimange, Gurthro Steenkamp, Albert Van Den Berg, Jacques Cronje, Fourie Du Preez, Wayne Julies, Jaco Van Der Westhuizen