The 8.1 magnitude quake off the southern coast late on Thursday was stronger than a devastating 1985 temblor that flattened swathes of Mexico City and killed thousands.
This time, damage to the city was limited, as the quake was deeper and further from the capital, but still shocking.
"It almost knocked me over," said Gildardo Arenas Rios, a 64-year-old security guard in Mexico City's Juarez neighborhood, who was making his rounds when buildings began moving.
The southern town of Juchitan in Oaxaca state, near the epicenter, was hit particularly hard, with sections of the town hall, a hotel, a bar and other buildings reduced to rubble.
"The situation is Juchitan is critical; this is the most terrible moment in its history," the town's mayor, Gloria Sanchez said, after the long, rumbling quake that also shook Guatemala and El Salvador.
The government said 25 people were killed in Oaxaca, and state governor Alejandro Murat said 17 of those were in Juchitan.
A spokesman for emergency services said seven people died east of Oaxaca in the state of Chiapas, where thousands of people living on the coast were evacuated from homes as a precaution when the quake sparked tsunami warnings.
Waves rose as high as 2.3 ft (0.7 m) in Mexico, the Pacific Tsunami Warning Center said, though that threat passed.
State oil company Pemex said it was checking for damage at its installations. President Enrique Pena Nieto said operations at the Salina Cruz refinery in the same region as the epicenter were temporarily suspended as a precautionary measure.
Woken in the night
Two children died north of Chiapas in Tabasco state, the local governor said. At least 250 people in Oaxaca were also injured, according to agriculture minister Jose Calzada.
Classes were suspended in much of central and southern Mexico on Friday to allow authorities to review damage.
In one central neighborhood of Mexico City, dozens of people stood outside after the quake, some wrapped in blankets against the cool night air. Children were crying.
Liliana Villa, 35, who was in her apartment when the quake struck, fled to the street in her nightclothes.
"It felt horrible, and I thought, 'this (building) is going to fall,'" she said.
The US Geological Survey (USGS) said the 8.1 magnitude quake had its epicenter in the Pacific, 54 miles (87 km) southwest of the town of Pijijiapan at a depth of 43 miles.
Allen Husker, a seismological expert at the geophysical institute of the National Autonomous University of Mexico, said the quake had rewritten the record books.
"It's the worst quake (in Mexico) in more than 100 years," Husker said.
Across the Pacific Ocean, the national disaster agency of the Philippines put the country's eastern seaboard on alert for possible tsunamis, though in the end no evacuations were ordered.
Rescue workers labored through the night in badly affected areas to look for people who were possibly trapped in collapsed buildings. By early on Friday, the human cost of Mexican quake appeared to be less severe than many far less powerful tremors.
Windows were shattered at Mexico City airport and power went out in several neighborhoods of the capital, affecting more than one million people. The cornice of a hotel came down in the southern tourist city of Oaxaca, a witness said.
People in Mexico City, one of the world's largest cities, ran out into the streets in pajamas and alarms sounded after the quake struck just before midnight.
"I had never been anywhere where the earth moved so much. At first I laughed, but when the lights went out, I didn't know what to do," said Luis Carlos Briceno, an architect, 31, who was visiting Mexico City. "I nearly fell over."
Helicopters buzzed overhead looking for damage to the city, which is built on a spongy, drained lake bed.
Authorities reported dozens of aftershocks, and President Pena Nieto said the quake was felt by around 50 million of Mexico's roughly 120 million population, with further aftershocks likely. He advised people to check their homes and offices for damage and gas leaks.