At least 58 people have been killed after one of the most powerful earthquakes ever recorded in Mexico struck off the country's southern coast.
The quake, which hit minutes before midnight on Thursday, toppled hundreds of buildings, triggered tsunami evacuations and sent panicked people fleeing into the streets in the middle of the night.
It was strong enough to cause buildings to sway violently in the capital city more than 650 miles (1,000 kilometres) away.
People still wearing pyjamas ran out of their homes and gathered in frightened groups.
Rodrigo Soberanes, who lives near San Cristobal de las Casas in Chiapas, the state nearest the epicentre, said his house "moved like chewing gum".
The furious shaking created a second national emergency for Mexican agencies already bracing for Hurricane Katia on the other side of the country.
The system was expected to strike the Gulf coast in the state of Veracruz early on Saturday as a category two storm that could bring life-threatening floods.
The head of Mexico's civil defence agency confirmed the deaths of 45 people in the southern state of Oaxaca.
Another 10 people died in Chiapas and three more in the Gulf coast state of Tabasco.
The worst-hit city appeared to be Juchitan, on the narrow waist of Oaxaca known as the Isthmus.
About half of the city hall collapsed in a pile of rubble, and streets were littered with the debris of ruined houses.
Mexico's capital escaped major damage, but the quake terrified sleeping residents, many of whom still remember the catastrophic 1985 earthquake that killed thousands and devastated large parts of the city.
Families were jerked awake by the grating howl of the capital's seismic alarm.
Some shouted as they dashed out of rocking apartment buildings.
Even the famous Angel of Independence Monument swayed as the quake's waves rolled through the city's soft soil.
Elsewhere, the extent of destruction was still emerging.
Hundreds of buildings collapsed or were damaged, power was cut at least briefly to more than 1.8 million people and authorities closed schools on Friday in at least 11 states to check them for safety.
The earthquake's impact was blunted somewhat by the fact that it was centred 100 miles (160 kilometres) offshore.
It hit off Chiapas' Pacific coast, near the Guatemalan border with a magnitude of 8.1 - equal to Mexico's strongest quake of the past century.
It was slightly stronger than the 1985 quake, the US Geological Survey (USGS) said.
The epicentre was in a seismic hotspot in the Pacific where one tectonic plate dives under another.
These subduction zones are responsible for producing some of the biggest quakes in history, including the 2011 Fukushima disaster and the 2004 Sumatra quake that spawned a deadly tsunami.
The quake struck at 11.49pm on Thursday (4.49am GMT on Friday), and its epicentre was 102 miles (165 kilometres) west of Tapachula in Chiapas.
It had a depth of 43.3 miles (69.7 kilometres), the USGS said.
Dozens of strong aftershocks rattled the region in the following hours.
The Pacific Tsunami Warning Centre said waves of 3.3 feet (1 metre) above the tide level were measured off Salina Cruz, Mexico.
Smaller tsunami waves were observed on the coast or measured by ocean gauges elsewhere.
The centre's forecast said Ecuador, El Salvador and Guatemala could see waves of a meter or less.
Authorities briefly evacuated a few residents of coastal Tonala and Puerto Madero because of the warning.
In neighbouring Guatemala, President Jimmy Morales appeared on national television to call for calm while emergency crews surveyed damage.
Officials later said only four people had been injured and several dozen homes damaged.