Scotland withstood both a typhoon and an earthquake on the eve of their win-or-bust showdown with Japan but found themselves blown out of the World Cup as the super-charged hosts claimed a 28-21 win in Yokohama.
Gregor Townsend's men needed an eight-point triumph to book a quarter-final slot and it looked promising when Finn Russell put them ahead early.
But the Brave Blossoms hit back with a series of ceaseless attacks as they repeatedly crashed through the Dark Blues to secure top spot in Pool A and a rematch with their 2015 victims South Africa in Tokyo next Sunday.
Kenki Fukuoka grabbed a double, while star winger Kotaro Matsushima scored his fifth of the tournament - but it was prop Keita Inagaki who finished off a stunning move that will be hard to beat for try of the tournament.
Scotland refused to go down without a fight but second-half scores from forwards WP Nel and Zander Fagerson were not enough to prevent the Scots suffering their second pool exit in three tournaments.
The climax to the group stage at Yokohama's International Stadium nearly did not take place as a magnitude 5.7 quake coincided with Super Typoon Hagibis' violent collision with Japan's east coast.
The storm left at least two dozen dead and scores more injured but the Scots got the go-ahead to play their final group fixture after Yokohama was spared the worst of the "explosive" super cyclone's brunt.
Townsend knew his team would have to prove their strength of character in front of a 70,000 sell-out crowd dominated by home fans.
The emotion round the arena was palpable as a moment of silence in tribute to those who lost their lives in the wake of the storm was followed by a haunting rendition of the Japanese anthem.
But it was the Scots who punctured the growing din with Russell's seventh-minute opener.
The Racing 92 pivot fired a cross-field kick for Darcy Graham but the Edinburgh wing was immediately robbed by Fukuoka. Magnus Bradbury recovered possession before the forwards got to work softening up the home defence, making the space for Russell to dance his way into score.
But that was about as much possession as the Scots saw during what became a frenetic first half.
Japan's approach to this World Cup on home soil has been to attack with relentless tempo and they simply dropped a gear and launched themselves back at Townsend's team.
Jamie Ritchie won two vital turnovers inside 60 seconds but it was mere firefighting.
It took until the 18th minute before the hosts smoked their way down their opponents' right-hand side, with Fukuoka's stunning offload taking Stuart Hogg out of the equation before Matsushima raced in.
Scotland were scrambling to cover gaps but with Japan's energy levels running at maximum it was inevitable gaps would appear.
Matsushima spiked through the Dark Blues' defence before three pinball off-loads allowed Inagaki to flop over between the posts for a glorious score.
Lafaele's kick through then sent the galloping Fukuoka in for a try on the stroke of half-time, with the centre scoring again three minutes after the restart following an expert mugging of Chris Harris as he sealed Japan's bonus point.
Scotland were now all but out and had no choice but to go down swinging. They got a try back when Nel squeezed over after drives by Sam Johnson and Hogg finally handed them some territory in the Brave Blossoms' 22.
For a moment it looked as though a repeat of this year's famous Twickenham fightback might just be on when Fagerson crashed over on 56 minutes to cut the deficit to seven after Russell took the initiative by throwing a line-out to himself.
Had it not been for Pete Horne's forward pass, Hogg may even have squared the game up with 18 minutes left - but there was no late drama as Japan hung on for another monumental win.
Wales secured a World Cup quarter-final clash against France next Sunday - but they ended their Pool D campaign with an unconvincing 35-13 victory over Uruguay.
The Six Nations champions fielded only three of their probable last-eight starting XV - wing Josh Adams, centre Hadleigh Parkes and flanker Justin Tipuric.
But that could not excuse an often laboured, error-strewn display in Kumamoto as Uruguay - shock conquerors of Fiji last month - gave Wales a real battle.
Wales led by only a point at half-time following prop Nicky Smith's try that full-back Leigh Halfpenny converted.
Adams then claimed his fifth touchdown of the tournament, with Halfpenny again adding the extras, but Uruguay stayed in touch through two Felipe Berchesi penalties.
Unbeaten Wales finished top of their group with a best pool-phase performance since the 1987 World Cup.
England meanwhile qualified without losing a game and will face Australia in the first of the quarter-final ties on Saturday morning, 8.15am BST.
Ireland will face New Zealand immediately after that game at 11.15am..