The Wallabies beat the Springboks 41-39 at Bloemfontein with a last-minute penalty on Saturday in the Tri-Nations rugby series.
Australia scored four tries in the first 26 minutes and led 31-13 at half-time, but South Africa stormed back in the second half.
The outcome was uncertain until a long-range penalty was kicked by Wallabies fullback Kurtley Beale right on full time.
Beale, wing James O'Connor, hooker Stephen Moore and flanker and captain Rocky Elsom scored tries, all of which were converted by Matt Giteau.
The series has been won by New Zealand. Australia were second.