The effects were also felt in Guatemala, where at least one person died and homes along the border with Mexico were leveled.
Schools in at least 10 Mexican states and in Mexico City were closed on Friday as the president ordered an immediate assessment of the damage nationwide. In the hours after the quake, the National Seismological Service registered several aftershocks.
Still, the resounding feeling in the country was one, at least initially, of relief that the damage was not more widespread, given the nation’s vulnerability to earthquakes and the capital’s extreme density.
“We are assessing the damage, which will probably take hours, if not days,” said President Enrique Peña Nieto, who addressed the nation just two hours after the quake. “But the population is safe over all. There should not be a major sense of panic.”
Mexico is situated near several boundaries where portions of the earth’s crust collide. The quake on Thursday was more powerful than the one that killed nearly 10,000 people in 1985.
While the quake on Thursday struck nearly 450 miles from the capital and off the coast of Chiapas State, the one in 1985 was much closer to the city — so the shaking, coupled with Mexico City being on an ancient lake bed, proved much more deadly.
After the 1985 disaster, construction codes were reviewed and stiffened. Today, Mexico’s construction laws are considered as strict as those in the United States or Japan.
After the quake hit, people in Mexico City streamed out of their homes in the dark, wearing nightclothes, standing amid apartment buildings, cafes and bars in upscale neighborhoods and dense warrens of the city’s working-class communities. In the Condesa area, neighbors watched in awe as power lines swayed alongside trees and buildings. In several neighborhoods, the power went out, though it was restored within an hour, at least in the wealthier parts of the capital.
For a city used to earthquakes, Thursday’s quake left a lasting impression on residents, for both its force and duration.
“The scariest part of it all is that if you are an adult, and you’ve lived in this city your adult life, you remember 1985 very vividly,” said Alberto Briseño, a 58-year-old bar manager in Condesa. “This felt as strong and as bad, but from what I see, we’ve been spared from major tragedy.”
“Now we will do what us Mexicans do so well: take the bitter taste of this night and move on,” he added.
The quake occurred near the Middle America Trench, a zone in the eastern Pacific where one slab of the earth’s crust, called the Cocos Plate, is sliding under another, the North American, in a process called subduction.
The movement is very slow — about three inches a year — and over time stress builds because of friction between the slabs. At some point, the strain becomes so great that the rock breaks and slips along a fault. This releases vast amounts of energy and, if the slip occurs under the ocean, can move a lot of water suddenly, causing a tsunami.
Subduction zones ring the Pacific Ocean and are also found in other regions. They are responsible for the world’s largest earthquakes and most devastating tsunamis. The magnitude 9 earthquake off Japan in 2011 that led to the Fukushima nuclear disaster and the magnitude 9.1 quake in Indonesia in 2004 that spawned tsunamis that killed a quarter of a million people around the Indian Ocean are recent examples.
Those quakes each released about 30 times as much energy as the one in Mexico.
Mexico’s government issued a tsunami warning off the coast of Oaxaca and Chiapas after Thursday’s quake, but neither state appeared to have been adversely affected by waves. The Pacific Tsunami Warning Center said the largest wave recorded on Mexico’s Pacific Coast measured less than four feet.
In his address, Mr. Peña Nieto said that aftershocks were of greater concern than the waves generated by the earthquake, which he said was the strongest to hit the country in a century.
Rudy Gomez, 28, who lives in the Condesa neighborhood of Mexico City, said that he spoke to relatives in Chiapas by phone after the quake and that they were all fine. They were worried, however, about the aftershocks.
“After the earthquake, there were three more,” he said of the aftershocks in Chiapas. “They are just waiting to see if there is another one to come, but right now they are O.K.”
Juchitán, in the state of Oaxaca, appeared particularly hard-hit, as part of City Hall collapsed and there were reports of damage to buildings across the city. In a video posted on the Facebook page of a local television station, Pamela Terán, who introduced herself as a city councilor, begged the state and federal authorities for help.
“Please, we urgently need as much help as you can send,” she said. “We need hands and manpower to try and dig out the people that we know are buried under the rubble.”
The same TV station, Cortamortaja, reported the collapse of a hospital in Juchitán and showed images of doctors and nurses treating patients in the backyard.
In Guatemala, the military was out Friday morning assessing the damage, found mainly in the western part of the country.
In Huehuetenango, bricks and glass were strewn on the ground as walls in the city collapsed. Quetzaltenango, Guatemala’s second-largest city, which was beginning to recover from a tremor in June, suffered more damage to its historic center.