The 8.1 magnitude quake late on Thursday (local time) 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.
Elsewhere in the country, the quake tore through buildings, forced mass evacuations and triggered alerts as far away as Southeast Asia.
"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 epicentre, 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," said mayor Gloria Sanchez after the long, rumbling quake that also shook Guatemala and El Salvador nearby to the south.
Shocked residents stepped through the rubble of dozens of collapsed buildings including houses, a flattened Volkswagen dealership and Juchitan's battered town hall.
"Look at what it did to my house," said Maria Magdalena Lopez, in tears outside its shattered walls. "It was horrifying, it fell down."
Alma Rosa, sitting in vigil with a relative by the body of a loved one draped in a red shroud, said: "We went to buy a coffin, but there aren't any because there are so many bodies."
State governor Alejandro Murat said 25 people died in Oaxaca, 17 of them in Juchitan.
A spokesman for emergency services said nine people died east of Oaxaca in the state of Chiapas, where thousands of people in coastal areas were evacuated as a precaution when the quake sparked tsunami warnings.
Waves rose as high as 0.7m in Mexico, the Pacific Tsunami Warning Centre said, though that threat passed.
State oil company Pemex said it was checking its installations for damage and closed the Salina Cruz refinery in the same region as the epicenter as a precautionary measure. It began to restart the 330,000 bpd refinery on Friday afternoon.
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 assess damage.
People ran into the streets in Mexico City, one of the world's largest cities with an estimated population of more than 20 million, and alarms sounded after the quake struck just before midnight.
In one central neighborhood, dozens stood outside, 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 in her nightclothes.
"It felt horrible, and I thought, 'this (building) is going to fall,'" she said.
The US Geological Survey (USGS) said the quake's epicentre was in the Pacific, 87km southwest of the town of Pijijiapan at a depth of 69km.
John Bellini, a geophysicist at the USGS National Earthquake Information Centre in Golden, Colorado, said Thursday's quake was the strongest in Mexico since an 8.1 quake struck the western state of Jalisco in 1932.
Across the Pacific, the national disaster agency of the Philippines put the country's eastern seaboard on alert for possible tsunamis, although no evacuations were ordered.
Rescue workers searched through the night for anyone trapped in collapsed buildings but by early Friday the toll appeared to be less severe than that seen in 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.
Helicopters buzzed overhead looking for damage to the city, which is built on a spongy, drained lake bed that amplifies earthquakes along the volcanic country's multiple seismic fault-lines, even when they occur hundreds of kilometres away.
Authorities reported dozens of aftershocks, and President Pena Nieto said the quake was felt by around 50 million of Mexico's roughly 120m population, with further aftershocks likely. He advised people to check their homes and offices for damage and gas leaks.
Mexico is evaluating whether the quake will trigger a payout from a World Bank-backed catastrophe bond, Finance Minister Jose Antonio Meade said on Friday. Meade said the bond's coverage could reach $150m, depending on magnitude and location.
But he said Mexico has sufficient funds to pay for a clean-up whether the bond was triggered or not.
Mexico is currently also being threatened on its eastern coast by Hurricane Katia.
The category one hurricane is about 300km south-east of Tampico and has sustained winds of 140km/h the National Hurricane Center says.
Photo: AFP A video grab shows damage to a building in downtown Oaxaca.