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 6:47 p.m. Saturday 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.
The quake interrupted the annual silver festival in the tourist city of Taxco, midway between Acapulco and the capital.
A deep rumbling sound lasted for several seconds, then the whole city went dark as the ground shook. People ran out of hotels in the historic center of the old mining town and joined others who had been enjoying a band concert in the main plaza.
As people milled about, some illumination was provided from police pickup trucks doing security duty at the festival. After about 10 minutes, the band started up again and people began dancing.
The power was out for about two hours and cellphone service was sporadic. Some people sat on restaurant terraces dining by candlelight and the full moon.
Associated Press writers Mark Stevenson and Lisa Adams in Mexico City, Sergio Flores in Acapulco and Michael Weissenstein in Taxco contributed to this report.