The U.S. Geological Survey said the quake in the Pacific Coast state of Guerrero had a preliminary magnitude of 5.4. The southern state's government said it had initiated security protocols but did not immediately report damage or injuries.
Many office workers evacuated their buildings after the quake set off alarms in Mexico City but Mayor Miguel Angel Mancera said in a message from his Twitter account that there were no immediate reports of damage or injuries.
Mexico City is vulnerable to distant earthquakes because much of it sits atop the muddy sediments of drained lake beds. They jiggle like jelly when quake waves hit.
The magnitude-8.1 quake in 1985 that killed at least 6,000 people and destroyed many buildings in Mexico City was centered 250 miles (400 kilometers) away on the Pacific Coast.