Alejandro Murat told local television that 17 of the deaths were recorded in the southeastern town of Juchitan.
The quake hit offshore in the Pacific at 11:49 pm about 100 kilometers from the coastal town of Tonala in far southern Chiapas state, Mexico's seismologic service said.