Tsunami alerts were lifted on Tuesday for the U.S. West Coast and western Canada after a magnitude-7.9 earthquake struck in the Gulf of Alaska, sending the state's coastal residents inland to seek shelter from possible tidal waves.

In Alaska, people packed into high schools and other evacuation centers after the quake hit shortly after midnight local time (0900 GMT).

Officials had warned residents as far south as San Francisco to be ready to evacuate coastal areas but by 5:15 a.m. PST (1315 GMT) the U.S. National Weather Service had lifted all tsunami advisories, watches and warnings for California, Oregon Washington and Alaska. Canadian officials lifted one for coastal British Colombia.

In Alaska, residents gathered in shelters on Kodiak Island, the closest land point to the temblor, around 160 miles (250 km) southeast of Chiniak, Alaska, at a depth of 25 km - considered shallow but with broader damage - according to the U.S. Geological Survey (USGS).

There were no immediate reports of injuries or damage from the quake, which was initially measured at magnitude 8.2.

"People are fine," said Neil Hecht, assistant principal of Kodiak High School, which was sheltering a few hundred people. "Spirits are high."

Long lines of traffic formed in coastal communities including Homer and Seward, Alaska, residents said on social media.

In Homer, a few hundred cars were packed into its high school parking lot. Shawn Biessel, a 32-year-old park ranger, and his mother were in the lot, a few hundred feet above sea level.

"It was a really obvious, pretty strong, long quake. A good rumbler," Biessel said in a phone interview. "It went on for a solid minute and after a while we thought we should get outside."

NWS Tsunami Alerts tweet

Police drove through Biessel's neighborhood with flashing lights to alert residents to evacuate, Biessel said.

San Francisco briefly warned residents within three blocks of the Pacific Ocean or five blocks of San Francisco Bay to prepare to evacuate. That warning was later lifted.

Earthquakes of similar magnitude are not uncommon in Alaska, which is seismically active. The state has recorded 11 tremors with a magnitude of 7 or greater within 373 miles (600 km) of Tuesday's quake over the past century, according to Zachary Reeves, a USGS seismologist in Golden, Colorado.

The largest U.S. earthquake ever recorded was a magnitude-9.2 temblor in Alaska in March 1964, causing tidal waves of more than 100 feet (30 m) high that killed 131 people.