Australia beat South Africa 23-17 in wet Brisbane to earn their first win in this year's Rugby Championship.
The holders had the misfortune of playing world champions New Zealand in their first two games and, having lost both heavily, had to beat the Springboks to avoid being also-rans.
The visitors led 14-3 after 18 minutes, but Australia made it 13-14 at half-time and took a decisive nine-point advantage on 61 minutes.
Michael Cheika's men, for whom inside centre Bernard Foley scored 18 points, could have won by more had it not been for several mistakes in attacking positions.
South Africa made an ideal start when number eight Warren Whiteley barged over for a third-minute try, with Elton Jantjies converting.
A Foley penalty reduced the deficit and rewarded Australia pressure, but the Springboks crossed again on 18 minutes when Adriaan Strauss intercepted and Johan Goosen finished off a move up field. Jantjies again converted.
Australia responded strongly, Will Genia finding Adam Coleman out wide for the lock to dive over in the corner in the 28th minute.
Foley converted from out wide and added a penalty from a similarly difficult position to make it a one-point game at the break.
South Africa second-rower Eben Etzebeth was sin-binned soon after half-time and Foley kicked the Wallabies ahead from the resulting penalty.
With the man advantage, the hosts thought they scored in the corner through Samu Kerevi, but he was ruled to have had a leg in touch.
Australia's advantage grew in the 61st minute, by which time the Boks were back to 15 men, when Foley went through a gap after sustained home pressure and converted his try.
Cheika's side squandered further chances but it mattered little.