The quake sowed panic in the sprawling city of 20 million people, many of whom have memories of the quake 32 years ago that killed some 10,000 people in Mexico City.
"I'm so worried. I can't stop crying. It's the same nightmare as in 1985," one resident in a plaza in the capital, Georgina Sanchez, 52, sobbed to AFP.
The US Geological Survey put the quake's magnitude at 7.1. Mexico's Seismological Institute said it measured 6.8 on its scale, but later revised it to 7.1.
The institute said the quake's epicenter was seven kilometers (four miles) west of Chiautla de Tapia, in the neighboring state of Puebla.
Tuesday's quake occurred hours after authorities had conducted an earthquake drill.
AFP journalists captured images of collapsed buildings, a car crushed by rubble, and debris-strewn streets.
City residents also posted photos online of damage to buildings in their neighborhoods.
Emergency officials warned people not to smoke in the street, warning of possible ruptured gas pipes.
Alfredo Aguilar, a 43-year-old resident, said the quake was "really strong -- buildings started to move."
He added that he saw a woman who fainted. "People started to run."
(This story has not been edited by NDTV staff and is auto-generated from a syndicated feed.)