Hoiles broke Wales' hearts in the last minute
Australia: (12) 29
Tries: Palu, Sharpe, Giteau, Hoiles
Cons: Mortlock (3)
Wales: (17) 23
A try with the last move of the match from replacement Stephen Hoiles denied Wales a first win over the Wallabies in Australia since 1969.
Tries: Gareth Thomas, Robinson
Cons: Hook (2)
Pens: Hook (2)
The tourists stormed into an early 17-0 lead with tries from Jamie Robinson and Gareth Thomas, on his record 93rd cap.
Line-out problems helped Australia hit back, tries from Wycliff Palu, Nathan Sharpe and Matt Giteau making it 22-20.
James Hook's late drop-goal looked to have won it for Wales, but a final all out attack saw Hoiles in at the corner.
The sides meet again in Brisbane next Saturday as they build towards a 15 September clash in the World Cup pool stages in Cardiff.
Fans will be hoping for a repeat of this thriller at Sydney's Telstra Stadium, where both sides made nervous, error-strewn starts.
From an attacking position Aussie debutant Sam Norton-Knight - a late replacement for the injured Stephen Larkham - sent a poor pass behind Stirling Mortlock.
The centre dropped it, allowing Chris Czekaj to collect and hack forward where Hook gathered deep in the Wallabies' half and fed Thomas.
Gareth Thomas scored an early try to celebrate his cap record
The visitors' captain showed great strength to celebrate his Welsh-record 93rd-cap by claiming his 38th Test try, also a national record.
Australia's other debutant, Julian Huxley, then felt the pressure of Colin Charvis' rush defence and threw an interception pass to Robinson, the centre showing the pace to sprint home from 70m.
Turnover ball nearly saw Lee Byrne in for another long-range try, Mark Gerrard just hauling him down, but the Aussies yielding a penalty for Hook to make it 17-0.
The Wallabies elected to take a kickable penalty to touch and were rewarded after a strong series of forward drives, Palu barging over in the corner to begin the comeback.
As Wales struggled to secure possession, Australia began to move through the phases, a dangerous chip through forcing Byrne to concede a 5m line-out.
The Wallabies gathered safely and patiently worked an opening for Sharpe, who brushed aside a weak Robert Sidoli tackle for a converted try.
Wales failed to capitalise on an excellent Sonny Parker break, leaving the score 17-12 at the break, and continued to struggle with their line-out in the second half.
A series of Australian mistakes saw Wales encamped on their line, though, and their reward came with Hook's second penalty.
But the tourists immediately conceded turnover ball in their own 22, and Giteau's show-and-go down the blind-side saw the scrum-half over underneath the posts.
Mortlock converted, and a Welsh ruck offence allowed the centre to put Australia ahead for the first time with a penalty to make it 22-20.
Hook had an immediate chance to restore the advantage, but missed with a penalty from in front of the posts.
The game looked to be drifting from Wales, before Gerrard, having safely fielded a long kick into his 22, inexplicably let the ball slip from his grasp for a Wales scrum.
Charvis charged from the base, delivering quick ball for Hook to slot over a drop-goal.
Wales tried to close out the game, but a Gareth Cooper chip was well gathered by Huxley who hammered Wales back into their half.
A relentless attack either side of the final hooter left the Wallabies with a huge overlap and - as Hook just failed to grab a desperate interception - the ball was floated to Hoiles, who made no mistake in the corner.
Australia: Huxley, Gerrard, Mortlock, Ashley-Cooper, Mitchell, Norton-Knight, Giteau, Dunning, Moore, Shepherdson, Sharpe, Chisholm, Elsom, Waugh, Palu.
Replacements: Gregan for Ashley-Cooper (66), Robinson for Dunning (53), Freier for Moore (73), Vickerman for Chisholm (67), Smith for Waugh (53), Hoiles for Palu (73). Not Used: Staniforth.
Wales: Byrne, G. Thomas, Robinson, Parker, Czekaj, Hook, Phillips, I. Thomas, Rees, A. Jones, Cockbain, Sidoli, Charvis, G. Thomas, J. Thomas.
Replacements: Henson for Robinson (67), Cooper for Phillips (72), C. Jones for I. Thomas (73), Hibbard for Rees (74), Owen for Cockbain (36). Not Used: Morgan, Sweeney.
Referee: Jonathan Kaplan (SA)