A powerful earthquake struck off an island in the Gulf of Alaska, prompting a tsunami threat that sent the US state’s residents along the southern coast and western Canada fleeing for higher ground just after midnight.

After a few intense hours, the tsunami warning was cancelled, allowing people to return home from shelters. There were no immediate reports of damage, not even on Kodiak Island, the closest land to the epicentre of the magnitude 7.9 quake.

For Alaskans accustomed not only to tsunami threats but also to regular drills, the early morning alert that made mobile phone alarms go off still created some fretful moments. The phone message read: “Emergency Alert. Tsunami danger on the coast. Go to high ground or move inland.”

Keith Perkins got the phone alert and later heard the sirens going off in his southeast Alaska hometown of Sitka.

He said people on Facebook were chattering back and forth about whether this was real or not and what they should do.

Given the magnitude of the earthquake, Perkins said he thought it best to head to the high school, a tsunami evacuation point, even though in the past he felt his home was at a “high-enough spot.”

“I figured I’d probably just better play it safe,” he said.

The magnitude 7.9 earthquake was recorded in the Pacific Ocean at 12:32am about 170 miles southeast of Kodiak, home to one of the nation’s largest Coast Guard bases.

The quake prompted the tsunami warning stretching thousands of miles along Alaska’s southern coast, from Attu in the Aleutian Islands to Canada’s border with Washington state. Kodiak is located about 200 miles south of Anchorage, the state’s largest city, which was not under a tsunami threat.

Elsewhere in the United States, Washington state, Oregon, California and Hawaii were under tsunami watches, which eventually were lifted. Officials in Japan say there was no tsunami threat there.

People reported on social media that the quake was felt hundreds of miles away, in Anchorage. Reports varied about how long the quake’s shaking lasted, depending on where you were.

In the popular cruise ship town of Seward, about 110 miles south of Anchorage, fire chief Eddie Athey said the quake felt like a gentle rattle and lasted for up to 90 seconds.

“It went on long enough that you start thinking to yourself, ‘Boy, I hope this stops soon because it’s just getting worse’,” Mr Athey said.

The earthquake woke Kodiak Police Lieutenant Tim Putney from his sleep. He estimates it shook for at least 30 seconds but admits his time frame might be skewed by sleeping through some of it.

“I’ve been in Kodiak for 19 years that was the strongest, longest lasting one I’ve ever felt,” he said by telephone.

Mr Putney said there were no immediate reports of damage reported to Kodiak police. The state emergency management agency also had no immediate reports of damage. The Alaska Earthquake Information Centre categorised the shaking intensity as light.

Kodiak was projected to get the first tsunami wave, and officials warned residents to evacuate if they lived in low-lying areas. Residents scrambled to safety, and some sought refuge in schools that were transformed into shelters above the 100-foot level. The wave never materialised there or in other coastal communities like Homer and Seward, and the warning was soon cancelled.