Replacement full-back Dan Biggar kicked a late penalty as Wales claimed a first success in 14 games over nemesis Australia with an error-strewn 9-6 victory at the Millennium Stadium on Saturday to boost their confidence ahead of next year's Rugby World Cup.
Australia lock Ned Hanigan was penalised for not rolling away after making a tackle and Biggar kicked Wales to a famous win following a contest that saw both sides commit numerous unforced errors and show a lack of cutting edge.
Wales's Leigh Halfpenny, usually so deadly off the tee, landed two penalties but also missed two very kickable three-pointers, the second from directly in front of the posts on a nervous night in Cardiff.
It was by no means a classic, but for Wales coach Warren Gatland it was a seventh victory in a row and potentially a pivotal moment in his build-up to the global showpiece in Japan next year when the sides will meet again in the first-round pool stage.
The defeat compounded Australia's dismal season with Michael Cheika's side having won only three of their 11 tests. Saturday's result represented their first defeat against Wales in a decade.
Gatland had spoken in the build-up about making sure his side closed out games from winning positions and while Australia were to a certain extent the architects of their own downfall with sloppy play, he will be pleased with the way his team managed the final five minutes.
Both teams struggled at set-pieces in the first half, Wales with their line-outs and Australia at the scrum, and they went into the break level at 3-3.
The home side should have been in front but Halfpenny, to everyone's amazement including his own, sliced a short-range kick from in front of the posts wide.
Australia started the second period with more front-foot ball and they managed to quicken up the breakdowns, but they turned down two chances to kick penalties in favour of attacking line-outs.
From the first they knocked on at the resulting maul and in the second instance they botched their line-out and lost possession.
Halfpenny put the home side in front with 13 minutes remaining after Australia were penalised for offside, but the visitors hit back with a penalty from the touchline by replacement fly-half Matt Toomua that looked set to steal a draw.
Wales had the last say, though, as they put pressure on Australia just outside the visitors' 22, leading to Hanigan's indiscretion and Biggar's winning penalty three minutes from the end.
"We've done everything right in how we're building the squad and we feel like we're in a good place," Gatland said.
"It's always nice to get that win against a Southern Hemisphere team and it puts a bit of pressure on the guys who play against Tonga next week."