Japan produced a scintillating display of attacking rugby then withheld a spirited Scottish fightback to triumph 28-21 on a memorable night in Yokohama on Sunday, reaching the Rugby World Cup quarterfinals for the first time in their history.
Wing Kenki Fukuoka led the way with two tries, while Kotaro Matsushima and Keita Inagaki also scored as the hosts held off a fierce second-half assault from a team they had lost against in all seven of their previous meetings.
When Japan beat South Africa four years ago -- having won only one of their previous 24 World Cup matches -- it was considered the greatest shock in rugby history. When the two nations meet in the last eight next weekend, Japan will feel a win would be much less of a shock, given their victories over Ireland and Scotland in Pool A.
Japan were faster, sharper and more inventive than Scotland on Sunday, and they were roared on by the vast majority of the delirious, red-clad 72,00 crowd, absolutely relentless in everything they did as they became the first tier-two team to reach the last eight since Fiji in 2007.
Having won all four of their matches to top Pool A, Japan relegated Ireland to runners-up, who will play New Zealand next.
Sunday's Pool A match was given the go-ahead only hours before it kicked off after an inspection of the damage caused by Typhoon Hagibis. The fixture proved a wonderfully uplifting occasion for the country after the death and destruction wrought by the storm.
Scotland were first on the board with a Finn Russell try after seven minutes, but Japan hit back with a brilliantly worked, high-tempo score that set the tone for the night.
Fukuoka tore down the left and as he was tackled to the floor, slung a one-armed pass into the arms of the supporting Matsushima to go over and detonate an explosion of noise.
If that was good, their next score was a contender for try of the tournament. Fukuoka and Matsushima again put on the afterburners and then a mesmerizing series of offloads and sidesteps ended with Shota Horie presenting supporting prop Inagaki with an unmissable opportunity.
Japan were playing with a speed and intensity that the Scots just could not live with and got a third try at the end of the half when Tim Lafaele slipped through a deft grubber that bounced perfectly into the arms of Fukuoka.
It was then bedlam two minutes into the second half when Fukuoka stripped Chris Harris and galloped clear for a fourth and bonus-point-clinching try.
The Scots, who came from 31-0 down to draw 38-38 with England in the Six Nations in March, dredged up that Twickenham spirit from somewhere as WP Nel and Zander Fagerson scored to get back their team within seven points with 25 minutes to go.
It was relentless Scottish pressure and desperate, at times demented Japanese defending from then on, but the hosts held out for another famous victory in what became a deafening cauldron in Yokohama.
It was only the second time Scotland have failed to reach the last eight -- the other coming in 2011 -- but they can have few complaints, bookending wins over Russia and Samoa with defeats by Ireland and the hosts.
"We had a mountain to climb after that first half, but we started climbing it and I thought the effort the players put in to get back to within seven points was excellent," said Scotland coach Gregor Townsend.
"We were obviously aware that this was huge for the home nation. The atmosphere was absolutely fantastic and you didn't want to be the team that was losing in that atmosphere."
Japan, meanwhile, march on to face the Springboks -- two-time World Cup winners.
"Tonight we went another level," said Japan coach Jamie Joseph. "They wanted it as much as the Scots and gave as much as they could. This is what it takes to win big test matches."