(CNN) Ravaged by Typhoon Hagibis , Japan perhaps got the huge lift it needed when its rugby team beat Scotland 28-21 on home soil to reach a first ever World Cup quarterfinal.

The team's victory came hours after Japan's worst storm in decades battered much of the country with hurricane like winds and incessant, overpowering rain, killing dozens of people.

Residents had to be airlifted from homes, there was considerable flooding -- especially in and around Tokyo -- and flights were canceled from the capital's two main airports of Narita and Haneda.

Four from four in Pool A, how far can this @JRFURugby team go at #RWC2019 ? #JPNvSCO pic.twitter.com/jS0pu1hv3r

With three games already canceled this weekend because of the storm -- downgraded to a tropical depression Sunday -- and its aftereffects, doubts surrounded the host's clash with Scotland in Yokohama, near Tokyo.

But despite flooding near the stadium, organizers decided Sunday morning after an inspection the game in Pool A would proceed. A moment's silence was held beforehand, as it was ahead of Tonga's 31-19 win over the US and Wales' 35-13 win over Uruguay, both earlier Sunday.

"I really want to acknowledge the families that have lost people in the typhoon," Japan coach Jamie Joseph, a former New Zealand international, said. "It really motivated our team.

"We talked about that this morning as a group and the players really wanted to play because while we are celebrating tonight there are a lot of people that aren't. We'd like to acknowledge that."

Scotland were obviously keen for the crunch clash to go ahead, with reports suggesting it was considering a legal case if called off. In that case, the game would have been declared a 0-0 draw, putting Japan and Ireland through.

It was likely the biggest game in Japan's rugby history, having agonizingly missed out on a quarterfinal spot at the last World Cup in 2015 despite winning three Pool games.

Scotland needed a victory to have any hopes of progressing at Japan's expense and while only one spot separated the nations in the world rankings, the visitors might have been the sizable favorites since they only failed to make the quarterfinals once in World Cup history.

And when fly-half Finn Russell touched down in the seventh minute, there was a hush from most of the 70,000 in attendance. Darcy Graham played a key role, stripping Japan's leading World Cup 2019 scorer going into the game, Yu Tamura, deep in Japan's half.

Japanese response

Impressively, it did little to detract Japan, however. Japan bossed possession and handled impeccably.

"From my team, the whole World Cup, we prepared really well, the players put their bodies on the line every week," said Joseph. "But tonight they went another level I felt. They wanted the game as much as the Scottish team. They gave everything they could.

"Everyone gave 150% and that's what it takes to win big Test matches."

Even after Tamura missed a penalty from 30 meters, Japan kept pushing and responded with a try from the speedy, powerful Kotaro Matsushita -- the hat-trick hero against Russia.

The majestic Kenki Fukuoka played a brilliant pass to Matsushita as he was being tackled, inches away from falling to the grass.

A darting run by Matsushita set up Keita Inagaki's try in the 26th minute and the 14-7 lead was nothing more than Japan deserved.

JUST WATCHED Rugby in Japan: Japan's rugby Mecca Replay More Videos ... MUST WATCH Rugby in Japan: Japan's rugby Mecca 02:52

No action was taken against Jonny Gray after a head on head tackle on Shota Horie -- Horie appeared to be dipping down -- but Allan Dell was penalized following a scrum to give Tamura another penalty kick.

Again he was off target although he converted Fukuoka's try just before halftime for a seemingly hefty 21-7 lead. Fukuoka sped towards the line and ably gathered Timothy Lafaele's low kick.

The game looked to be out of reach when man-of-the match Fukuoka stripped Chris Harris and ran untouched for another try in the 43rd minute.

It was now 28-7 and the quarterfinals were well in sight.

Scottish comeback

But a pair of quick, converted tries from WP Nel and substitute Zander Fagerson in the 50th and 56th minutes suddenly had Japan in a mild panic as the lead shriveled to 28-21.

It could have been worse. In the 62nd minute, Harris seemed like he wouldn't be denied as he sprinted to the line. But he was put through by a forward pass from Pete Horne, negating the sequence.

JUST WATCHED Meet rugby superfan Daisuke Komura Replay More Videos ... MUST WATCH Meet rugby superfan Daisuke Komura 03:00

Horne was in agony.

But when the final whistle blew, Japanese fans went wild.

Japan, a perfect 4-0 in the Pool, faces South Africa next weekend. In the other quarterfinals, two-time defending champion New Zealand meets Ireland, Australia plays England and Wales battles France.

Can Japan go all the way?

Joseph didn't say that but his team's confidence is growing.

"The Japanese haven't really trusted themselves in tough moments and tonight, and I guess the last four matches, the guys have got a lot of belief now and realize what it takes to get across the line.

"The more we win, the more that belief will grow."