A Rob Horne try and Bernard Foley's subsequent conversion one minute from time gave Australia a 24-23 victory over South Africa in the Rugby Championship in Perth.
The Wallabies trailed South Africa for much of the match but a 65th-minute yellow card for Bryan Habana, in his 100th Test, swung the game in the hosts' favour and their persistence paid off as the Springboks defence finally buckled in the closing stages.
The result means they also have their first victory of this year's competition and will look forward to next Saturday's encounter against Argentina with renewed confidence.
A fortnight to reflect on a 51-20 defeat to New Zealand in Auckland saw Wallabies coach Ewen McKenzie replace Kurtley Beale with Foley at fly-half and the Aussies made a blistering start as full-back Israel Folau scored inside 90 seconds.
Morne Steyn reduced the deficit to two points when he kicked the first of his six penalties as the Wallabies were blown by Irish referee George Clancy for not releasing.
Cornal Hendricks put South Africa into an 8-5 lead in the 13th minute, cutting inside from the right wing to touch down. The visitors went in 14-11 ahead at the break as Foley and Steyn exchanged penalties.
After Foley briefly levelled the game after the restart, Steyn kicked three penalties in a row to put Springboks in control. The momentum then swung back in the hosts' favour when Habana was sin-binned for a high tackle with 15 minutes left and Foley reduced South Africa's winning margin to six points.
With the clock ticking down, a one-handed offload from Folau found Tevita Kuridrani and he passed to Horne, who cut in from the left wing to score Australia's second try with less than two minutes to go before Foley held his nerve to slot the conversion to send the majority of the home crowd into a frenzy.
Earlier, Julian Savea scored two tries as New Zealand earned a hard-fought 28-9 victory over Argentina in McLean Park.