The replacement earned Wales a 29-28 win with the final kick of the game.
Substitute Rhys Priestland’s penalty with the final kick of a frantic game thwarted Australia and sent a 68,000 Principality Stadium crowd wild.
Australia number eight Rob Valetini was sent off after just 15 minutes for a dangerous tackle on Wales lock Adam Beard.
Beard played no further part in the game as a result, but Wales were pushed to the wire and outscored 3-2 on tries by a resilient Wallabies outfit.
Hooker Ryan Elias and centre Nick Tompkins scored tries for Wales, yet it was fly-half Dan Biggar’s goalkicking that proved the difference, as he amassed 16 points through four penalties and two conversions, until Priestland struck.
Australia, desperate for a win following losses to Scotland and England, made Wales fight every inch of the way despite the numerical disadvantage, as wings Andrew Kellaway and Filipo Daugunu touched down, with scrum-half Nic White also scoring.
James O’Connor booted two penalties and two conversions, yet his conversion attempt of Daugunu’s late score hit the post, and Wales could breathe a huge sigh of relief, despite Kurtley Beale’s 78th-minute penalty.
Wales centre Uilisi Halaholo featured for a first start of the autumn campaign, while wing Josh Adams, prop Tomas Francis and number eight Aaron Wainwright all recovered from injuries.
But the Wallabies were without 118 times-capped skipper Michael Hooper because of a foot injury, so prop James Slipper led the side.
Australia made a dream start, going ahead after just three minutes as they scored a try from their first attack.
Powerful prop Taniela Tupou charged into space and put Wales on the back foot, before centre Hunter Paisami’s cleverly-placed kick allowed wing Kellaway a simple finish, and O’Connor converted.
Biggar opened Wales’ account through a fifth-minute penalty, yet Tupou continued to make his presence felt by having an instant dominant impact in the scrums.
The Wallabies then suffered a huge blow when Valetini was sent off.
His head-on-head high challenge floored Beard, who went off, and referee Mike Adamson had no option but to brandish a red card.
Ben Carter went on for Beard, and Australia were left to play more than a hour with 14 men, although the Wallabies led 10-6 after Biggar and O’Connor exchanged penalties.
It was the sixth time in 12 Tests this year that Wales had seen a player sent off against them.
Australia’s woes continued when Beale received a yellow card for a deliberate knock-on, giving Wales a temporary two-man advantage.
And they immediately punished Australia when scrum-half Tomos Williams broke from a lineout and sent Elias over for a try that Biggar converted.
O’Connor put Australia level through his second penalty, but Wales held the upper hand as half-time approached and Biggar completed a penalty hat-trick that made it 16-13 at the break.
Wales extended their lead eight minutes into the second half as Tompkins interrupted an Australian move when the ball bounced off him, and he gathered possession to sprint away unopposed.
Biggar kicked the conversion, yet Wales were then forced into a change when wing Louis Rees-Zammit limped off and was replaced by Johnny McNicholl.
Australia continued to push hard in the game, but Wales appeared to hold all the aces midway through the third quarter, despite seeing substitute Gareth Thomas sin-binned for a reckless challenge.
It was poor discipline by the Ospreys forward, and offered Australia a glimmer of hope at a time in the game when Wales should have been looking to press the accelerator.
And the Wallabies struck on the hour-mark when White finished off a sweeping move, and O’Connor’s conversion cut the deficit to just three points.
Biggar, though, restored a degree of order by booting a 64th-minute penalty, and Wales led 26-20 before late drama unfolded, Australia briefly led, then Priestland grabbed the glory.