A rare and powerful 8.2-magnitude earthquake struck southern Mexico late Thursday, killing at least 32 people as seismologists warned of a tsunami of more than 10 feet.
The quake hit offshore in the Pacific about 75 miles southwest of the town of Tres Picos in far southern Chiapas state, the US Geological Survey said, putting the magnitude at 8.1.
Mexico's president said the earthquake magnitude was 8.2, the strongest in a century in the country.
The country's seismologic service initially gave a magnitude of 8.4, which if confirmed would be the most powerful ever recorded in this quake-prone country. 
The quake shook a large swath of the country and was felt as far north as Mexico City - 600 miles from the quake epicenter - where people ran out of their homes in their pajamas as buildings trembled and swayed.
A tsunami warning and the prospect of aftershocks kept the nation on alert.
"Based on all available data ... widespread hazardous tsunami waves are forecast for some coasts," the Pacific Tsunami Warning Center said.
 a collapsed building in Matias Romero, Oaxaca, Mexico
A collapsed hotel in Matias Romero, Oaxaca, Mexico CREDIT:  EFE/CIVIL DEFENSE
"Tsunami waves reaching more than three meters above the tide level are possible along the coasts of Mexico," it said, with lower waves in other countries.
The tsunami warning was for the coasts of Mexico, down through Central America into Guatemala, El Salvador, Costa Rica, Nicaragua, Panama and Honduras, and as far south as Ecuador.
The quake was felt in much of Guatemala, which borders Chiapas.
President Enrique Peña Nieto ordered schools to remain closed Friday in Chiapas and Mexico City so officials could inspect for structural damage.
He said on Twitter he was overseeing the emergency response from the National Disaster Prevention Center's headquarters.
In Mexico City, people ran out of buildings after hearing earthquake warning sirens go off just before midnight (6am UK time Friday).
Patients and doctors of a hospital of Mexico City wait outside after the earthquake
Patients and doctors of a hospital of Mexico City wait outside after the earthquake CREDIT: EPA
The quake struck at a depth of 21 miles, the USGS said.
It is the strongest to hit quake-prone Mexico at least since 1985, when an 8.1-magnitude earthquake in Mexico City killed more than 10,000 people.
Picture on social media showed buildings were damaged in Chiapas state in Mexico
Picture on social media showed buildings were damaged in Chiapas state in Mexico CREDIT:TWITTER/@JUSTGONZO
The authorities have since instituted a stricter building code and developed an earthquake alert system using sensors placed on the coasts.
Mexico sits atop five tectonic plates, whose movement makes it one of the most earthquake-prone countries in the world.
More updates to follow.

Reporter live on air when the earthquake hits

A remarkable video has emerged from Mexican television network Televisa, showing their reporter in the studio reading the news, only to be interrupted by the earthquake alarm. The room starts to shake and the reporter is forced to leave the live broadcast and seek shelter away from the perilous studio lights.
The camera then cuts to a wide shot of Mexico City, which starts shaking violently.