The quake, which President Enrique Peña Nieto said measured 8.2, struck in the Pacific, about 87km (54 miles) south-west of Pijijiapan.
Oaxaca and Chiapas states bore the brunt of the damage and dozens of aftershocks have been reported.
A tsunami warning was initially issued but later lifted.
The quake, which struck at 23:50 local time on Thursday (04:50 GMT Friday), was felt hundreds of miles away in Mexico City, with buildings swaying and people running into the street.
President Peña Nieto said about 50 million Mexicans would have felt the tremor and that the death toll might rise. His office said he would travel to Chiapas to survey the damage.
At least 25 people were killed in Mexico’s Oaxaca state, 17 of them in the town of Juchitán, officials said.
Another seven were reported killed in Chiapas and three more, including two children, died in Tabasco state. President Peña Nieto said more than 200 people had been injured.
At least one person was killed in Guatemala, its president has said.
Images showed collapsed buildings across Oaxaca. In Juchitán, the municipal palace and a number of other structures were destroyed or badly damaged.
Click here to continue reading.