The U.S. Geological Service initially estimated the quake at magnitude at 6.8, but downgraded it to 6.7 and then 6.5. A quake of that magnitude is capable of causing severe damage, although the depth of this temblor lessened its impact.
The USGS said the quake occurred at a depth of 40.3 miles (64.9 kilometers). It was centered about 26 miles (42 kilometers) southwest of Iguala in Guerrero and 103 miles (166 kilometers) south-southwest of Mexico City.
Mexico's Interior Department said the quake was felt in parts of nine states.
Humberto Calvo, undersecretary of Guerrero's Civil Protection agency, said three deaths had been reported in the state. He said one man was killed when a house's roof collapsed in Iguala, a second died in the small town of Ixcateopan and the driver of a cargo truck was killed by rocks that fell on the vehicle driving on the toll highway linking Acapulco with Mexico City.
Calvo said a secondary highway between the two cities was blocked in two places by rockslides.
High-rises swayed in the center of Mexico City for more than a minute, and shoppers were temporarily herded out of some shopping centers until the danger passed.
Mexico City's mayor, Marcelo Ebrard, reported by Twitter that no major damage had been reported. He said power failed in some parts of the city.
People in one part of Mexico City's upscale Condesa neighborhood ran out of their houses and gathered in the streets, hugging each other while some shook and began to cry.
On one street, a group of women joined hands in a circle, closed their eyes and began to pray.
"Please God, help us and let everything be OK," said one. "It's OK. It's OK. Everything is OK."
Parts of Mexico City rest on the shaky soil of a former lake bed, which tends to magnify the effect of earthquakes. An 8.1-magnitude quake in 1985 killed as many as 10,000 people in the city.
In Acapulco, which is in Guerrero, hundreds of anxious tourists congregated in the street after fleeing rocking buildings that are strung along the coastal boulevard. Patrons also left a movie theater complex.
Authorities said they found no structural damage and had no reports of injuries in the Pacific resort, which was about 87 miles (140 kilometers) from the quake's epicenter.
Rogelio Trujillo, chief of security at a Soriana department store in Acapulco, said perfume bottles, groceries and paintings had been shaken off shelves and customers ran out.
Alberto Orbe, a radio operator for the city's Civil Protection agency, said the office had received many phone calls from panicked residents.