JUCHITÁN DE ZARAGOZA, Mexico — Thousands of homes in this city were severely damaged. Half of the 19th-century city hall, with its 30 arches, collapsed. The main hospital here was so devastated that staff members evacuated patients to an empty lot and worked by the light of their cellphones.
By the time the earthquake’s tremors finally faded, at least 36 people in Juchitán de Zaragoza were dead.
“It’s a truly critical situation,” Óscar Cruz López, the city’s municipal secretary, said Friday. “The city,” he said, and then paused. “It’s as if it had been bombed.”
Over all, the earthquake — the most powerful to hit the country in a century — killed at least 58 people in Mexico, all of them in the southern part of the country that was closer to the quake’s epicenter off the Pacific Coast.
The earthquake, which had a magnitude of 8.2 and struck shortly before midnight on Thursday, was felt by tens of millions of people in Mexico and in Guatemala, where at least one person died as well.
In Mexico City, the capital, which still bears the physical and psychological scars of a devastating earthquake in 1985 that killed as many as 10,000 people, alarms sounding over loudspeakers spurred residents to flee into the streets in their pajamas.
The city seemed to convulse in terrifying waves, making street lamps and the Angel of Independence monument, the capital’s signature landmark, sway like a metronome’s pendulum.
But this time, the megalopolis emerged largely unscathed, with minor structural damage and only two of its nearly nine million people reporting injuries, neither serious, officials said.
In the southern part of the country, however, at least 10 people died in Chiapas State and three died in neighboring Tabasco, including two children: one when a wall collapsed and the other after a respirator lost power in a hospital, officials said.
Chiapas officials said that more than 400 houses had been destroyed and about 1,700 others were damaged.
In Oaxaca State, at least 45 people were killed, including the 36 in here in Juchitán, a provincial city of 100,000.
“A total disaster,” the mayor, Gloria Sánchez López, declared in a telephone interview in which she appealed for help. “Don’t leave us alone.”
President Enrique Peña Nieto flew to the region on Friday afternoon to assess the damage. And several leaders in Latin America and elsewhere offered assistance to Mexico, including the presidents of Colombia, Chile, Ecuador, Bolivia, Venezuela and Spain.
Mexico is also facing the additional threat of Hurricane Katia, which is gathering strength in the Gulf of Mexico and expected to make landfall in Veracruz State early Saturday.
“You can count on us,” President Juan Manuel Santos of Colombia said on Twitter.
Residents in Juchitán spent the morning using backhoes and their bare hands to dig through the wreckage of collapsed buildings and pull the injured, and the dead, from the rubble.
By early afternoon, the efforts had mostly turned from rescues to a cleanup operation, though the municipal secretary, Mr. Cruz, said that workers were still trying to claw through the mounds of debris left by the collapse of the city hall to reach one last victim, a police officer. Nobody knew if he was still alive.
“It is a nightmare we weren’t prepared for,” said a member of the City Council, Pamela Teran, in an interview with a local radio station. She estimated that 20 to 30 percent of the houses in the city were destroyed.
“A lot of people have lost everything, and it just breaks your heart,” she added, bursting into tears.
With the hospital — the region’s main medical center — destroyed, officials converted a grade school into a makeshift clinic and moved the hospital’s patients and the hundreds of injured survivors there.
Local officials appealed to state and federal governments for aid to help with the recovery.
“It’s impossible to resolve this catastrophe, to respond to something of this magnitude, by ourselves,” Mr. Cruz said.
Aftershocks continued through the day Friday, unnerving the city’s residents, many of whom spent much of the day out in the street rather than return to their homes, said Juan Antonio García, the director of the Juchitán news website Cortamortaja.
Reports of damage elsewhere in the region continued to emerge throughout the afternoon. In Union Hidalgo, just to the east of Juchitán, the mayor reported that about 500 houses had been destroyed.
Schools in at least 10 Mexican states and in Mexico City were closed on Friday as the president ordered an assessment of the damage nationwide.
“We are assessing the damage, which will probably take hours, if not days,” President Peña Nieto said in televised comments to the nation two hours after the quake.
Throughout the day Mexicans lined up at emergency collection centers around the country to donate food, water and other supplies for delivery to the earthquake victims.
Mexico is situated near the colliding boundaries of several sections of the earth’s crust.
The quake on Thursday was more powerful than the one in 1985 that flattened or seriously damaged thousands of buildings in Mexico City.
While the quake on Thursday struck nearly 450 miles from the capital, off the coast of Chiapas State, the one in 1985 was much closer to the capital, so the shaking 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.
Though many Mexicans have grown accustomed to earthquakes, taking them as an immutable fact of life, Thursday’s quake left a lasting impression on residents of the capital 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. “This felt as strong and as bad.”
“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, which led to the Fukushima nuclear disaster, and the magnitude-9.1 quake in Indonesia in 2004, which 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.
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.