Wales' Rhys Priestland kicked a penalty after the hooter as the hosts poured more misery on Australia with a 29-28 victory at the Principality Stadium on Saturday following an early red card for visiting No. 8 Rob Valetini.
Valetini became the fifth player to see red against Wales in the last 12 months but could have few complaints after his dangerous tackle on lock Adam Beard after 14 minutes resulted in a clash of heads.
Hooker Ryan Elias and centre Nick Tompkins scored tries for the home side, who failed to drive home their numerical advantage and were seconds away from losing before they were awarded an offside penalty in the last play of the game.
Australia, who have lost all three matches on their tour after defeats to Scotland and England, scored tries through wings Andrew Kellaway and Filipo Daugunu, plus scrum-half Nic White but, having highlighted the need to improve their discipline in the week, let themselves down again.
"It was a tough one. We made it more difficult for ourselves than we had to," Wales captain Ellis Jenkins told Amazon Prime.
"They [Australia] played some lovely stuff. It's lung-busting trying to defend it. Sometimes you need to win ugly and we'll take that today.
"The red card is one of those ones. It's clumsy, but these days it is a red card. We didn't want to count on that to win us the game, and we probably didn't do that as well as we could at times."
Full-back Kurtley Beale looked as though he had kicked the visitors to the win when he landed a 45-metre penalty in the last minute, but Wales went up the other end and bashed at the Australian line, eventually forcing the infringement.
Priestland, on for the battered Dan Biggar, showed few nerves as he booted the penalty between the posts to record a third win in a row for Wales over Australia.
It would have been a remarkable victory for the tourists had they been able to hold on. They were down to 13 men for 10 minutes in the first half when Beale was sin-binned for a deliberate knock-on.
They can at least take heart from the fight they showed having trailed 23-13 with under 20 minutes to go, having taken advantage of a yellow card for Wales prop Gareth Thomas that levelled the numbers.
After White scored a try, Daugunu added another as the home side wilted in the face of their attack.
James O'Connor struck the post with his conversion for the latter score, which would have made a difference in the end, but the exhausted Australians could not hold out and ended the year with a third straight loss.
"We put a lot of pressure on ourselves, a lack of discipline hurt us. In test matches you can't win when you put yourself under that pressure," Australia captain James Slipper said.
"We started well, we were happy with that, we wanted to do that but then we lost our No. 8. That changes a lot of things.
"We put ourselves in a position to win it at the end. They showed a lot of character to fight tooth and nail. I couldn't be more proud of the boys, but Wales were just good enough to get the win."