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.
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.)
Follow NDTV for latest election news and live coverage of assembly elections 2019 in Maharashtra and Haryana.
Subscribe to our YouTube channel, like us on Facebook or follow us on Twitter and Instagram for latest news and live news updates.