A powerful earthquake centred near the southern Mexico resort of Huatulco has killed at least four people, affected buildings in Mexico City and sent thousands fleeing into the streets.

Mexico President Andres Manuel Lopez Obrador said one person was killed and another injured in a building collapse in Huatulco, Oaxaca.

Otherwise he said reports were of minor damage such as broken windows and collapsed walls. Oaxaca Governor Alejandro Murat later said a second person was killed in an apparent house collapse in the tiny mountain village of San Juan Ozolotepec.

Federal civil defence authorities reported two more deaths: a worker at the state-run oil company, Pemex, fell to his death from a refinery structure, and a man died in the Oaxaca village of San Agustin Amatengo when a wall fell on him.

Pemex also said the quake caused a fire at its refinery in the Pacific coast city of Salina Cruz, relatively near the epicentre. It said one worker was injured and the flames were quickly extinguished.

Mr Lopez Obrador said there had been more than 140 aftershocks, most of them small.

Seismic alarms sounded mid-morning with enough warning for residents to exit buildings. Power was knocked out to some areas.

The US Geologic Survey said the magnitude 7.4 quake hit at 10:29am local time along Mexico’s southern Pacific coast at a depth of 16 miles. The epicentre was seven miles south-west of Santa Maria Zapotitlan in Oaxaca state.

It was felt in Guatemala and throughout south and central Mexico.

In Huatulco, a laid-back beach destination known for surfing and small protected coves, the earthquake knocked goods off shelves and some rubble from buildings.

Mari Gonzalez of the Princess Mayev hotel in Huatulco said staff and guests were able to evacuate the building before the quake, but that 45 minutes after the initial quake they were still outside as strong aftershocks continued.

Local news media reported damage to some buildings in the state capital, Oaxaca city. State officials said they were looking for damage.

The USGS estimated that some two million people felt strong or moderate shaking, and another 49 million felt weak or light shaking.

The earthquake hit a quake-prone region where four underground tectonic plates come together. In the past 35 years, there have been at least seven magnitude 7 or greater earthquakes, killing around 10,000 people — most of them in a 1985 8.0 quake.