For 38 harrowing minutes, residents and tourists in Hawaii were left to believe that missiles were streaming across the sky toward the Pacific island chain after an erroneous alert Saturday morning by the state’s emergency management agency.

“Ballistic missile threat inbound to Hawaii,” warned an 8:07 a.m. message transmitted across the state’s cellphone networks. “Seek immediate shelter. This is not a drill.”

Only after an inexplicable delay by the state agency — during which residents scrambled to seek shelter and contact relatives — was a subsequent message sent describing the missile warning as a “false alarm.”

The frightening mistake, which Gov. David Ige, D, later attributed to a state employee’s errant push of a button, prompted outrage and calls for an investigation into how such an error could occur and take so long to correct. The episode underscored the already heightened level of anxiety at the western edge of the United States amid mounting tensions with North Korea over its nuclear arsenal and the menacing social media exchanges between President Donald Trump and its leader, Kim Jong Un.

On the island of Oahu, Adam Kurtz of Palolo woke up four minutes after the mass alert was sent and began calculating how much time he and his wife might have to get to safety — assuming there could be no more than 15 minutes between the warning and any missile’s arrival.

Kurtz said that he and his wife grabbed the pets, shut the windows and sheltered in their bathroom. “We just jumped out of bed. ... We were more clearheaded than we expected and didn’t panic as much,” he said. “In never really sank in.”

Kurtz said he learned that the alert was false from a friend who contacted state Department of Defense officials.

Ige said the false warning was “a mistake made during a standard procedure at the changeover of a shift and an employee pushed the wrong button.” At a later news conference, Ige and Hawaii Emergency Management Agency Administrator Vern Miyagi promised that no single person will be able to cause such an error in the future.

Miyagi said a rule has already been put in place to mandate that two people be present before the button is pushed to alert for a drill or emergency. He also said a cancellation message template will be created for such an error scenario so a delay like Saturday’s does not happen again.

But the explanation on how the alert was sent came only after concern over the mistaken missile warning had spread to U.S. military command posts and been brought to the attention of Trump, who is spending the weekend at his Mar-a-Lago estate in Florida.

The false alert prompted U.S. military officials to scan systems that monitor missile launches; they determined almost instantly that there was no threat. But officials described confusion over whether or how the military should correct a state-issued alert.

At the North American Aerospace Defense Command, which tracks the skies for threats to the United States, U.S. troops manning the watch floor confirmed within minutes that there were no missiles bearing down on Hawaii. That information was quickly relayed to state officials, said Navy Lt. Cmdr. Joe Nawrocki, a spokesman for the command.

But Hawaii struggled to issue a comprehensive correction. The Hawaii Emergency Management Agency transmitted its first “no missile threat” message within 12 minutes of the mistaken alert, but that revision only went out on the agency’s Twitter account.

It wasn’t until 8:45 a.m. that the agency was able to issue a stand-down message across the same cellphone and cable television networks that had spread the initial, erroneous warning. By that time, officials from Hawaii including Rep. Tulsi Gabbard, D, had taken it upon themselves to distribute stand-down messages on social media.

“What happened today is totally inexcusable,” Sen. Brian Schatz, D, said in a posting on his Twitter account. “The whole state was terrified. There needs to be tough and quick accountability and a fixed process.”

Deputy White House press secretary Lindsay Walters said Trump had been briefed on the false missile warning in Hawaii. She added that it was “purely a state exercise.” Officials in Hawaii did not characterize the errant alarm as part of any drill or exercise.

A senior U.S. official told The Post that Trump was at the golf course at Mar-a-Lago when the alarm was sounded and knew “soon after” that it had been determined false. Deputy national security adviser Ricky Waddell briefed Trump, who also spoke to White House Chief of Staff John Kelly and national security adviser H.R. McMaster.

Trump later tweeted, but not about Hawaii; he decried the media for “Fake News” and appeared to call out author Michael Wolff, who wrote the new book “Fire and Fury” about his campaign and presidency.

“So much Fake News is being reported. They don’t even try to get it right, or correct it when they are wrong. They promote the Fake Book of a mentally deranged author, who knowingly writes false information. The Mainstream Media is crazed that WE won the election!” the president tweeted Saturday night.

In the hours after the false alert, images and postings on social media showed people flooding area highways, crowding into police stations and seeking shelter in concrete structures including parking garages. One unconfirmed Twitter posting showed a resident lowering children through a manhole in a sidewalk.

Tricia Padilla, 39, of Kauai, her husband and their two children, aged 10 and 12, hid in a steel shipping container on the lawn of their property.

“We just flew into full on mom-and-dad mode and tried to protect our kids from the panic of it,” she said. “My husband had my kids put on jeans and tennis shoes and we gathered up as quickly as we could what we thought we needed to have with us.”

They brought with them cereal, protein bars, cookies, apples, a cooler bag filled with turkey, water, a 5-gallon bucket to use as a toilet and toilet paper.

“My 10-year-old was kind of melting, sitting at my feet rocking, saying, ‘Mom, are we going to die today? Why won’t you answer me?’ and I wanted to answer him, but I couldn’t. It felt like my worst mom moment,” Padilla said. end new

Said 10-year-old Evan Padilla, “I just felt like any breath could be my last. I just thought it was going to land and it was all going to be gone.”

Toni Foshee, a resident of Palolo, said she and a friend visiting from California reacted as if a hurricane were coming — making sure her cat was indoors, shutting windows and waiting.

“I think I was just kind of numb,” she said, adding that they learned the alert was false after calling the police.

“When I heard it, my stomach dropped,” said Roc Dias of Kaneohe, on Oahu.

U.S. military personnel stationed in Hawaii described moments of near desperation.

One Navy sailor, speaking on the condition of anonymity because he was not authorized to talk to reporters, said that he awoke Saturday morning in Honolulu to his girlfriend asking him about the alert. Shocked, he turned on the television looking for more information and called his mother in Massachusetts to let her know what had happened and say he loved her.

The sailor eventually called the Honolulu Police Department about 10 minutes later, and the dispatcher told him that the alert was a mistake.

“How can that happen?” he said of the error. “How can you allow to that to happen? There’s just an anger that goes with it. Even now, I’m shaken that it happened. You go from thinking you might die to this. It’s just a weird feeling.”

Because of its mid-Pacific location, Hawaii has long confronted the possibility that it would be the target of any North Korean attack on the United States. That worry has intensified in recent months amid escalating signs of conflict between Pyongyang and Washington.

The provocations between Trump and Kim have become increasingly personal. Earlier this month, Trump taunted Kim in a Twitter post, saying, “Will someone from his depleted and food starved regime please inform him that I too have a Nuclear Button, but it is a much bigger & more powerful one than his, and my Button works!”

Less than two months ago, Hawaii took the extraordinary step of reviving a statewide Cold War-style system of sirens designed to alert the population to a nuclear attack. Residents have heard the sirens during system tests in recent months, but the alarms remained quiet amid the false alert Saturday.

Although states often employ emergency communication networks developed with federal funding and rely on threat warnings from federal agencies, they operate emergency alerts independently. In California this year, for example, state alert systems were used to warn residents of fires and mudslides.

Richard Rapoza, a spokesman for the Hawaii Emergency Management Agency, said that missile alert warnings are typically prompted by notification over a dedicated communication line with U.S. Pacific Command.

Rapoza said there is a checklist the agency goes through to make sure the alert is accurate before an employee transmits any message across cell and television networks. “Our credibility is vital, and we are going to do whatever we can to make sure this never happens again,” he said. “We should have been able to cancel the alert immediately. It shouldn’t have taken that long. So we are going through our processes and procedures to figure out where that went wrong.”

Brittany Lyte and Courtney Teague in Hawaii contributed to this report. Anne Gearan contributed from Palm Beach. Josh Dawsey contributed from Washington.