A massive magnitude 8.2 earthquake and tsunami hit the northern coast of Chile, near the port of Iquique, and prompted a warning for the country's Pacific coast, Chilean officials have said.

Interior Minister Rodrigo Penailillo said five people were confirmed dead and attributed the deaths to heart attacks or being crushed.

The first waves hit the coast within 45 minutes of the quake, Chilean officials said, adding that the disaster forced evacuations along Chile's Pacific coast for fear of a tsunami. The waves generated were 2.11m tall, US officials said.

An earthquake of this size has the potential to generate a destructive tsunami that can strike coastlines near the

epicenter within minutes. - The Pacific Warning Center

Thousands of buildings have lost power, and hundreds of thousands of Chileans are spending the night away from their homes due to the evacuation order, which remains in effect for northern Chile.

Chilean President Michelle Bachelet declared parts of northern Chile hit by the earthquake to be disaster zones.

Bachelet said she would travel to the regions of Arica and Tarapaca on Wednesday, and send military officials to the areas to prevent looting and disorder.

Al Jazeera's Lucia Newman, reporting from the Chilean capital of Santiago, said that authorities were happy with how an evacuation plan was carried out.

"What we've been seeing on national TV is people running from the beach," Newman said. "They've been warned about a tsunami. That's the biggest concern for now."

Newman said the area near the coastline was flat and so there was no way of reaching high ground.

"It's a matter of getting away as far as possible - several kilometres," she said.

The earthquake hit an area that has been rocked by numerous quakes over the past two weeks.

Cars fleeing, buildings shaking

Live footage from Chilean television showed scores of cars driving away from the coastline at high speed and state television also broadcast viewer footage of the insides of buildings shaking as the earthquake struck.

"We're leaving with the children and what we can, but everything is clogged up by people fleeing buildings by the beach," said 32-year old Liliana Arriaza, who was driving away with her three children, told Reuters news agency.

The US Geological Survey said the quake was very shallow, only 10km below the seabed. It was centred 86km northwest of Iquique, Chile's main mining export port, Reuters said.

A tsunami warning was issued for the Pacific coast of Mexico through Central and South America.

"An earthquake of this size has the potential to generate a destructive tsunami that can strike coastlines near the

epicenter within minutes and more distant coastlines within hours," the Pacific Tsunami Warning Center said.

In 2010, an 8.8 magnitude quake triggered a tsunami that caused major damage in several coastal towns in central-south Chile and killed hundreds of people.

The strongest earthquake ever recorded on Earth also happened in Chile - a magnitude 9.5 tremor in 1960 that killed more than 5,000 people.