text: Media playback is not supported on this device
  The Six Nations champions trailed 9-6 at half-time, with Kurtley Beale kicking three penalties to Leigh Halfpenny's two.
  The Wales full-back landed two more to nudge the hosts 12-9 ahead on the hour.
  But with less than 30 seconds left, Beale scored in the right corner.
  "That's the worst defeat I've ever been involved with. To be in control really for the majority of the second half and in the last play of the game we slip-up. It's really hard to take."
  It was a desperate end to a dismal autumn for Wales, the game ending in further anti-climax as Halfpenny, after a man-of-the-match display, was taken off on a stretcher.
  Defeat means Wales will drop out of the top eight in the world rankings ahead of Monday's 2015 World Cup draw and will be in the third band of seedings.
  Already without three injured locks among a dozen casualties, Wales appeared to have lost another as early as the third minute when Luke Charteris got his head in the wrong place trying to tackle Scott Higginbotham and was forced to leave the field after lengthy treatment.
  The beanpole second-row re-emerged five minutes later to join Lou Reed, the Scarlets lock starting his first Test, in the Welsh engine room, but only lasted until half-time, Ryan Jones replacing him.
  Australia, playing their 15th Test in the last six months, showed few signs of physical or mental fatigue initially, despite Beale missing an early penalty.
  (provided by Opta)
  They were the first to demonstrate their attacking intent, Adam Ashley-Cooper cutting through the midfield and finding Drew Mitchell on the left wing, but Wales scrambled well in defence.
  The hosts were quick to respond. Wales won a scrum on their own line and Rhys Priestland, feigning to kick, instead passed to Jamie Roberts, who in turn released Alex Cuthbert to race 60m up the right touchline.
  But the giant wing appeared to delay before trying to find his support, allowing Berrick Barnes to force him into touch.
  Wales threatened a try on three more occasions in the first half, the first when Wycliff Palu narrowly beat Sam Warburton to Halfpenny's kick ahead after an electric break from the full-back. Then Liam Williams also opted for a kick rather than keeping ball in hand, before Australia won a turnover after Jonathan Davies had released Cuthbert.
  Instead it was Australia who opened the scoring in the 16th minute, Beale going for goal from the halfway line after Matthew Rees was penalised for going off his feet at a ruck.
  Halfpenny swiftly replied with a long-ranger from inside his own half, and kicked Wales into a 6-3 lead after 24 minutes when David Pocock, the Wallabies open-side playing his first match since August, was penalised at the breakdown.
  Beale soon levelled the scores with his second penalty from halfway and nudged his side ahead four minutes before half-time after Roberts was penalised for taking the ball into contact.
  Wales should have been level at the break, but Halfpenny missed a straightforward kick.
  The second half began along similar lines to much of the first, the hosts going through a multitude of phases before Australia turned the ball over at a breakdown.
  "Wales had control of the game and the defensive organisation was not good enough for the try. Australia took their one last chance. They need to redeem themselves in the Six Nations but have to play a lot better."
  Barnes pushed a snap drop-goal attempt wide as the Wallabies threatened, Wales requiring a crunching tackle from Halfpenny to deny Mitchell a try, after Barnes had sent the wing through.
  But Halfpenny levelled the scores in the 55th minute after Wales won a penalty at a scrum, and put the hosts in front again with his fourth successful kick on the hour.
  Australia brought on Mike Harris, the man who broke Welsh hearts with a last-ditch penalty to win the second Test in Melbourne in June, but the full-back missed an opportunity after 67 minutes when he dragged a straightforward attempt wide.
  With time ticking down, Wales messed up another line-out in the Australia 22, and the Wallabies broke out from their own line through Mitchell.
  Wales repelled the first thrust with another superb Halfpenny tackle, but the Wallabies came again and replacement Dave Dennis exploited an overlap to put Beale over in the right corner, albeit with a suspiciously forward-looking pass.
  After a lengthy delay while Halfpenny was attended to, captain Nathan Sharpe - after the 116th and final Test of a magnificent career - headed off into retirement by missing the conversion.
  Wales:  Halfpenny, Cuthbert, J Davies, Roberts, L Williams; Priestland, Phillips;  Jenkins, Rees, Andrews, Reed, Charteris, Shingler, Warbuton (capt), Faletau.
  Replacements:  Owens (for Rees, 66), Bevington, Lee,  R Jones (temp, for Charteris, 3-8, 41), Tipuric (for Faletau, 66), Knoyle, Biggar, S Williams.
  Australia:  Barnes, Cummins, Ashley-Cooper, Tapuai, Mitchell; Beale, Phipps;  Robinson, Polota-Nau, Alexander, Douglas, Sharpe (capt), Higginbotham, Pocock, Palu.
  Replacements: Moore (for Polota-Nau, 41), Slipper (for Robinson, 62), Kepu (for Alexander, 67), Dennis (for Higginbotham, 16), Hooper (for Douglas, 52), McKibbin, Harris (for Tapuai, 58), Ioane (for Cummins, 49).
  Referee: Wayne Barnes (England)
  Assistant referees: Romain Poite (France) and Greg Garner (England)
  TV: Marshall Kilgore (Ireland)
target: Wales slipped to an agonising seventh straight Test defeat and their eighth in a row against Australia as the Wallabies stole victory in a dramatic finale in Cardiff.