Some people evacuated buildings in the capital, but there were no immediate reports of damage or injuries. State officials in Michoacan also said they had no reports of casualties or damage.
The U.S. Geological Survey said the quake's epicenter was about 23 miles (38 kilometers) northeast of the Pacific port of Lazaro Cardenas. That is about 202 miles (327 kilometers) west-southwest of Mexico City.
The USGS said its preliminary reading of the quake gave it a magnitude of 5.9. Mexico's National Seismological Service put the magnitude at 5.8.
The tremor occurred 45 miles (73 kilometers) below the Earth's surface, the USGS said. The energy of a deep earthquake dissipates more than that of a shallow quake and generally causes less damage.