Millions of Japanese people awoke to "terrifying" text messages urging them to "evacuate to a sturdy building or underground" after North Korea fired a missile over the country.
TV and radio stations also interrupted regular programming to broadcast the "J-Alert", while bullet trains were temporarily halted as warnings went out over loudspeakers in towns in the northern island of Hokkaido.
The ballistic missile, fired at 5.58am local time, fell into the sea 735 miles (1,180 km) east of Cape Erimo.
Within three minutes of the launch, Prime Minister Shinzo Abe had ordered officials to gather and analyse incoming information.
At 6.02am the government sent out an alert nationwide warning system telling northern residents of the missile threat.
"Missile launch. Missile launch. A missile was fired from North Korea. Please evacuate to a sturdy building or basement," the text said.
The J-Alert was issued in 12 prefectures, including Hokkaido, making it the most widespread warning issued since the system began operating in 2007.
Ai Onodera, 33, of Hokkaido's capital Sapparo, said she was jolted awake by the message and immediately called her husband, who was away on a business trip.
"I was terrified that I wouldn't see him again," she told Reuters.
Some recipients admitted they were confused about how to respond to the warning.
One, still living in temporary housing after the March 2011 earthquake and tsunami, said on social media: "What do they mean, solid buildings? We don't have any."
"I was woken by the missile alert on my cellphone," said Ayaka Nishijima, 41, an office worker from Morioka, the capital of Iwate prefecture, 300 km (180 miles) south of Cape Erimo.
"I didn't feel prepared at all. Even if we get these alerts there's nowhere to run. It's not like we have a basement or bomb shelter, all we can do is get away from the window," she said.
Four minutes after the first public warning, at 6.06 am, the missile entered the air space over Hokkaido, according to government bulletins.
By 6.07 am, the missile - travelling at close to 7,500 miles per hour (12,000 km an hour) and a maximum height of 340 miles (550km) - had hurtled across the island and out to sea.
An alert from the government's Fire and Disaster Management Agency saying the missile had passed over Hokkaido was sent two minutes later.
"If you find suspicious things, please never touch them," it added.
"We felt helpless knowing there was nothing we could do even while a missile was passing through the skies of Japan," said Hiroaki Kumasaka, 38, who works at a publishing company and was at Tokyo station for a business trip up north.
"I sent a message to my family saying that 'Japan is no longer safe,' and the stranger standing next to me shared the same sentiments with me," he added.
The J-Alert was the third issued about a North Korean missile launch since 2007, reported the Asahi Shimbun.
Pyongyang has conducted dozens of ballistic missile tests under leader Kim Jong-un, the most recent on Saturday, but firing projectiles over mainland Japan is rare.
"North Korea's reckless action is an unprecedented, serious and grave threat to our nation," Mr Abe said.
The United Nations Security Council would meet later on Tuesday to discuss the test, diplomats said.
Andrew Kaz, a 24-year-old American working as an assistant language teacher in the eastern Hokkaido city of Kushiro said he was worried about the potential response from Japan and the US.
"I know this happened before but I feel small and rudderless," he said. "Everything seems like business as usual, but you can tell people are shaken up."
Growing threats from Pyongyang have prompted several coastal towns on Japan's main island of Honshu to hold missile drills. Hokkaido, a island of 5.5 million known for its ski resorts, seafood, beer and potatoes, was planning what appeared to be its first such drill this Friday.
Earlier this month, the 15-member Security Council unanimously imposed new sanctions on North Korea in response to two long-range missile launches in July.
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies