Reuters reporters in Mexico City said the earthquake seemed to go on for an unusually long period. There were no immediate reports of damage but residents ran out of apartment buildings and stores.
I was dreadfully afraid, I thought it was never going to end, said Laura Gonzalez, who was drinking in a bar in the capital when the quake struck.
Its epicenter was in the southwestern state of Guerrero and was 40 miles deep, the U.S. Geological Survey reported.
Power was knocked out in parts of the capital, but Mexico City Mayor Marcelo Ebrard said water services, the subway, and the airport were working normally.
A severe earthquake in 1985 killed thousands of people and wrecked parts of Mexico City.
(Reporting by Luis Rojas and Mica Rosenberg; writing by Krista Hughes; Editing by Kieran Murray)