Wales will face South Africa in the World Cup quarterfinals as a 15-6 defeat to Australia ensured Warren Gatland's side were forced to settle for qualifying second from Pool A.
Australia have now beaten Wales in all of their last 11 meetings and this impressive win at Twickenham means the Wallabies are rewarded with a less daunting clash against Scotland in the last eight.
Wales beat South Africa in Cardiff in November last year but they will have to be more clinical against the Springboks, as Australia managed to come through unscathed in the second half, despite enduring 10 minutes with 13 men.
Dan Biggar kicked six points for the Welsh but Australian fly-half Bernard Foley's five penalties was enough to edge an absorbing contest.
Wales were looking to beat Australia for the first time in 11 matches and avoid a World Cup quarterfinal showdown with South Africa.
Both sides knew their place in the last eight was secure but the prize for winning at Twickenham would be top spot in Pool A and a less fiendish knockout clash with Scotland.
Wales were boosted by the return of winger Liam Williams, who had recovered from concussion, while George North shifted to outside centre.
Australia full-back Israel Folau passed a late fitness test on a troublesome ankle injury but flanker Michael Hooper missed out through suspension.
Wales made a roaring start with Gareth Davies bursting down the right before his grubber kick through saw North bundle the ball over the line but the centre was held up.
Dan Biggar launched a cross-field kick moments later and while the Welsh fly-half failed to find Alex Cuthbert out wide, play was brought back for a penalty, which he slotted home for an early 3-0 lead.
Wales were enjoying the ascendancy in the scrum but Australian flanker Sean McMahon made his mark with a thumping tackle on Biggar, which had the crowd wincing at the big-screen replay.
Wales had dominated the opening 20 minutes but failed to convert possession into points and when Australia first entered their opponents' 22, they capitalised with a Bernard Foley penalty drawing the score level.
Growing in confidence, the Wallabies turned down a second penalty kick for the line-out, but when Justin Tipuric infringed again for entering a ruck off his feet, this time Foley turned to the tee and put his side into the lead.
Biggar and Foley exchanged another three points each, before the Welsh fly-half missed his first kick of the tournament shortly before the interval, as a brutal 40 minutes ended with Australia 9-6 ahead.
Both teams, eager to seize the initiative, raced out of the blocks after the restart with Welsh No.8 Taulupe Faletau enjoying an excellent break out wide.
Folau, perhaps not 100 per cent fit, had struggled in the opening half and the Australian fullback was fortunate not be penalised for a late and clumsy challenge on his opposite number Gareth Anscombe, who had just collected a high kick.
Wales' Faletau enjoyed no such generosity in the 49th minute as he was pulled up for a neck-roll, allowing Foley to convert a simple penalty and give Australia a six-point advantage.
Wales refused to lie down, however, as Davies blocked a Foley clearance before Australian scrum-half Will Genia was sin-binned for a cynical trip.
Scenting blood, Wales piled forward and thought they had scored when Faletau crashed through -- but the TMO showed the forward had spilled the ball at the crucial moment and play was brought back for a penalty.
Australia were rattled and their task became even tougher when Dean Mumm was sin-binned for repeat infringements at the line-out, reducing the Wallabies to 13.
With the two-man advantage, Wales simply had to capitalise but Australia put on a 10-minute masterclass in last-ditch defence, resisting their opponents' assault on their try-line with guts and organisation.
Unscathed by a single point and restored to full strength, Australia swarmed forward and almost scored themselves as Folau danced his way through two defenders but was dragged down just short of the line.
Foley ensured the attack did not go unrewarded as he kicked his fifth penalty to make it 15-6 with nine minutes remaining and Wales' disappointing night was compounded when Cuthbert was given a yellow card for a deliberate knock-on.
Foley skewed the kick wide but it did little to tarnish the Australians' satisfaction when the full-time whistle finally blew.