SYDNEY — Parts of New Zealand were evacuated on Friday after an 8.1-magnitude earthquake struck in the South Pacific, prompting officials to issue tsunami warnings for coastal areas.

The earthquake was recorded early Friday morning near the Kermadec Islands, which are between Tonga and New Zealand’s North Island, according to the U.S. Geological Survey.

The Pacific Tsunami Warning Center urged the public in the region to be vigilant and to closely monitor the situation.

“Tsunami waves have been observed,” the center said, adding that based on available data, “hazardous tsunami waves are forecast for some coasts.”

Following evacuation orders and warnings to move away from the coast, thousands of New Zealanders fled to higher ground, walking, driving and riding bicycles.

Several towns near the country’s northern coast emptied out within a few hours of tsunami warnings via sirens or text messages from the government.

“This has been a dynamic event that is constantly evolving,” Emergency Management Minister Kiri Allan said at a news conference on Friday. “People have done the right things in the region by picking up, packing up and by and large staying calm.”

Several people near the coast reported seeing disturbing signs of water receding and churning.

Speaking to Radio New Zealand, Daniel Thompson, a motel owner in Doubtless Bay, on the East coast of the North Island, described unusual changes in the tide that seemed to disturb local wildlife.

“The sea gulls have gone completely quiet, they’ve been just sitting and doing nothing,” Mr. Thompson said. “The bird activity has been very strange.”

People in Whangarei, in the Northland region, described an unusual color to the water in the harbor and the water level dropping, TVNZ reported.

New Zealand officials said that the tsunami threat would linger for several hours as geologists collected data on the impact of the earthquakes. Waves near the epicenter move quickly and then slow down and gain size as they approach land. In New Zealand, officials said the expected surge could reach as high as three meters, or nearly 10 feet.

“We are asking those who have moved to higher ground or inland to remain where you are until the official all clear is given,” said Ms. Allan, the emergency management minister. “We know that people may get a little, perhaps, tired or bored sitting at home or whatever it might be, but we are asking that people not leave those areas until we get the all clear.”

A tsunami watch that had been issued for the state of Hawaii was canceled, with forecasters saying that the islands no longer faced a threat. The watch had been in effect for a little more than an hour.

“This is a good reminder to stay vigilant and be prepared,” Gov. David Ige of Hawaii said on Twitter.

Less than two hours before the 8.1-magnitude earthquake, seismologists recorded a 7.4-magnitude earthquake about 31 miles west, the U.S. Geological Survey said. The agency said that the first earthquake was most likely what is known as a foreshock.

Six hours earlier, a 7.3-magnitude earthquake was reported about 560 miles to the south, seismologists said.

Damien Cave reported from Sydney, Neil Vigdor reported from Greenwich, Conn., and Natasha Frost reported from Auckland.