A magnitude 7.9 earthquake hit the Gulf of Alaska on Tuesday, prompting authorities to warn people in the area to move away from the coast in case it causes a tsunami.

The tsunami warning was then cancelled hours after emergency sirens sounded in Kodiak, a town of 6100 people on Alaska's Kodiak Island, one of the closest settlements to the epicentre.

"This is a tsunami warning. This is not a drill. Please get out to higher ground," said the announcer on local public radio station KMXT. "If you are on the flats, get up on one of the hills ... Just go high."

The quake, initially measured at magnitude 8.2, hit 256 kilometres southeast of Chiniak, Alaska at a depth of 10 kilometres at 09.31 GMT, the US Geological Survey said.

The quake prompted a temporary tsunami warning for parts of Alaska and Canada and a tsunami watch for the entire US west coast and Hawaii. It was later retracted.

"Based on all available data a tsunami may have been generated by this earthquake that could be destructive on coastal areas even far from the epicentre," the Pacific Tsunami Warning Centre initially said.

Japan's meteorological agency said it was monitoring the situation but did not issue a tsunami alert.