MEXICO CITY — Minutes before midnight, warning sirens blared across this earthquake-anxious capital.
This, in itself, was not unusual. Temblors are common here, and in recent years Mexico City has held annual disaster drills, revamped building codes and installed sophisticated sensors to be ready for an emergency. Many residents still have clear memories of the calamitous 1985 earthquake that killed at least 5,000 people here and left a quarter-million homeless.
But minutes after the sirens began wailing late Thursday, hanging houseplants started swaying and books tumbled from shelves. Plaster cracked. Streetlights shimmied like reeds in the wind. Lights went black. In pajamas and barefoot, with babies swaddled in blankets, residents rushed out of their apartments to wait in the darkened streets.
This was no drill.
This was an 8.2-magnitude earthquake, according to Mexican federal authorities, which would make it the most powerful one in Mexico in the past 100 years, and it was felt by some 50 million people. Mexico City, with many of its newer buildings built to withstand severe tremors, was spared significant damage, but the earthquake left pockets of destruction across southern states such as Oaxaca, Chiapas and Tabasco.
By Friday afternoon, Mexican authorities had put the death toll at 58 people, including 45 in Oaxaca and 10 in Chiapas. Mexican media published photos and video of collapsed buildings and rubble in the streets. The Anel Hotel in Oaxaca collapsed, but authorities said that people inside managed to escape and that there were not believed to be any casualties.
One of the worst-hit towns appeared to be Juchitan, with 31 people reported dead, according to the Mexican daily El Universal. There was severe damage at the city hall, a market, a car dealership and a hospital. Residents put out pleas on social media for help recovering people from the wreckage.
Three people died in Tabasco state, including an infant who perished when hospital electricity failed and a ventilator shut off, authorities said.
The earthquake was centered more than 600 miles from the capital in the Pacific Ocean off the coast of Tapachula, a town in Chiapas famous as a way station for Central American migrants headed to the United States.
Mexican authorities closed schools Friday in Mexico City and 11 states in the central and southern part of the country so they could check for damage to infrastructure.
The U.S. Geological Survey counted at least 20 aftershocks greater than magnitude 4.0. The shaking set off waves that washed up on the coast; some coastal residents evacuated their homes and sought shelter elsewhere.
The main quake was centered 43 miles underground, more than twice as deep as the one in 1985, and experts said that dampened its impact.
After the shaking stopped, Mexico City and other large cities emerged mostly unscathed. President Enrique Peña Nieto said more than 1 million people lost power but electricity was soon restored for most of them.
Since the 1985 quake, which destroyed or damaged an estimated 5,000 buildings in Mexico City, residents here remain wary of any temblors. The devastation left a profound impact on city activists and politics, ushering in demands for more-rigorous building standards. Authorities conduct anniversary drills to teach residents how to react.
Whereas there was one earthquake sensor in Mexico in 1985, now there are about 100 solar-powered sensors throughout the country. When a quake is detected, these sensors send automatic alerts to a network of 8,000 alarms, intended to provide about a minute of warning before the shock waves reach Mexico City.
Since the early 1990s, there have been various alarm systems in use in Mexico, including radio announcements, and by 2014 Mexico City had installed its current loudspeaker system, said Juan Manuel Espinosa, director of the Center of Instrumentation and Seismic Registry, a nonprofit civil society group.
While preparations have improved, Espinosa said that becoming complacent is dangerous and that the government should continue to expand the alert network.
"I don't want to give the impression that we are prepared and doing enough for a disaster. There are building standards that must be observed. There are many factors," he said. "If this earthquake had been half the distance between Chiapas and Mexico City, the scenario that we would be living through now would be totally different."
"One is never fully prepared for this," he added. "And it's been a long time since we've seen something of that magnitude in this city."
Gabriela Martinez contributed to this report.