MEXICO CITY — Miguel de la Madrid Hurtado, who led Mexico from 1982 to 1988 during economic crisis and a devasting earthquake, died Sunday at age 77, President Felipe Calderon announced on his Twitter account.

A spokeswoman for Calderon’s office speaking on condition of anonymity because she was not authorized to be quoted by the press confirmed Sunday that the message was posted by Calderon.

Calderon said he is “profoundly sorry for the death of ex-President de la Madrid.”

The cause of death was not immediately announced, but the former president had been hospitalized for respiratory problems since late last year.

Several false rumors about de la Madrid’s death surfaced in December, and Calderon even sent an incorrect tweet on his official Twitter account at that time offering condolences to the former president’s family. He corrected that false report minutes later.

During his presidency, d la Madrid pulled Mexico back from economic collapse but left it with a political crisis.

His term from 1982 to 1988 was a grim time for most Mexicans, a six-year hangover after a spending binge by the previous government, which had thought soaring oil prices would never fall. When they did, the buying power of Mexican salaries was slashed in half as inflation chewed up paychecks.

A magnitude-8.1 earthquake killed an estimated 9,000 people and flattened parts of the capital. A fiery explosion at a government gas facility killed more than 500 people on the outskirts of Mexico City. The government’s handling of the election to replace de la Madrid caused a political scandal that later helped topple the political system that dominated Mexico for most of the 20th century.

But the initial economic panic was so deep that many thought de la Madrid did well just by not making things worse.

As he put it just before leaving office, “I took a country with great problems and leave it with problems.”

Relations with the U.S., always crucial for any Mexican leader, were mixed.

De la Madrid got along well personally with President Ronald Reagan, but the two governments disagreed sharply over Central America, particularly Nicaragua, where Mexico was viewed by administration officials as perhaps the most stalwart noncommunist backer of the leftist Sandinista government.

Mexico also sometimes irritated the U.S. with its shared leadership of the so-called Contadora Group of Latin American nations, which contributed to ending Central America’s civil wars.

Relations with Washington were damaged when a U.S. drug agent, Enrique Camarena Salazar, was kidnapped, tortured and killed in Mexico in 1985.

U.S. officials accused several high-ranking Mexican officials of collaborating with traffickers who killed Camarena, though a Mexican judge sentenced drug lord Rafael Caro Quintero to 40 years in prison for his role in the Camarena slaying.

In an interview with The Associated Press before leaving office, de la Madrid said that the challenge of living next to such a wealthy and complicated country had fed Mexico’s sense of nationalism.

“Perhaps that is one of the great advantages of being a neighbor of the United States: our desire to continue being an independent and sovereign nation that rules its own destiny,” he said.