Bernard Foley overcame a wayward day from the kicking tee to slot a last-gasp penalty and put Australia into the World Cup semi-finals at the expense of a heartbroken Scotland.
Mark Bennett’s dramatic late interception try looked to have caused a huge upset for the Scots but referee Craig Joubert gave the Wallabies a controversial penalty with a minute remaining that Foley slotted for a 35-34 win.
It was a tough call on the Scots who were outscored five tries to three at Twickenham but led with only two minutes left.
Adam Ashley-Cooper, Drew Mitchell and Michael Hooper crossed in the first half for the Wallabies but Foley converted none of them.
Up the other end Peter Horne crossed while Gloucester Rugby's Greig Laidlaw added three penalties and a conversion for a half-time 16-15 lead.
After the break Sean Maitland – who will be playing Aviva Premiership Rugby with London Irish – saw yellow as Mitchell bagged his second and it appeared the Wallabies might run away with it.
But Scotland kept coming, Tommy Seymour keeping them in touch before Tevita Kuridrani looked to have done enough with the Wallabies’ fifth try.
Laidlaw’s boot remained metronomic however, before Bennett picked off a pass to go under the posts and send the Scottish fans wild – until Joubert and Foley broke their hearts late on.
After Ireland’s defeat earlier in the afternoon all northern hemisphere hopes turned to Scotland in the final quarter-final.
But Michael Cheika’s Wallabies have looked superb in this year’s tournament, emerging from the pool of death with a perfect record and they were right into their groove.
Foley could have scored as early as the fifth minute before Kuridrani broke a tackle down the right, fed Ashley-Cooper and the winger sprinted clear for a deserved first Australia try.
Foley – as would become a recurring theme during the first half – could not add the extras and Scotland, bystanders for the first ten minutes, were shaken into life.
Laidlaw slotted their first penalty and there was better to come.
Wave after wave of attacks in the Aussie 22 were rebuffed before Horne burst through a gaping hole in the middle of the breakdown to dot down untouched under the posts.
Laidlaw’s conversion, plus a subsequent penalty had the Scottish fans in dreamland with a 13-5 lead.
But in the final ten minutes before the interval the Wallabies began to re-assert their early dominance, Mitchell cantering over down the left after collecting Kurtley Beale’s fine miss pass.
Foley’s conversion was wide and a dominant Scotland scrum then won another penalty and Laidlaw showed his opposite kicker how to do it, his third penalty sailing over for a 16-10 lead.
The first-half scoring was not done there however, a driving maul on the stroke of the break dragging Hooper over the line but again Foley could not convert and belief coursed through Scottish veins as they went in at the break 16-15 to the good.
That optimism was soon dispelled however, Maitland given a harsh yellow card at the start of the second half for a deliberate knock-on and leaving a gap that Mitchell ruthlessly exploited for his second score of the game.
This time Foley added a testing conversion and at 22-16 you feared the worst for Vern Cotter’s troops.
Laidlaw and Foley then traded penalties, either side of an Ashley-Cooper try ruled out for an earlier knock-on, but when Maitland returned from the bin Scotland came again, Finn Russell charging down Foley’s chip and feeding Seymour who touched down.
The previously flawless Laidlaw missed with the tough conversion to leave the Wallabies 25-24 in front and Twickenham pumping.
But Kuridrani’s power proved too much with quarter of an hour to go, the centre barging over from short range and Foley adding the extras to open an eight-point lead.
Laidlaw slotted another penalty to close the gap and after the heavens opened Bennett picked off a pass to go under the posts, Laidlaw’s conversion putting them in front.
However Joubert awarded a penalty for accidental offside with two minutes left and Foley found his kicking boots to seal victory.