Updated

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 speak 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 earlier false report minutes later.

During his presidency, De 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 spending binge by the previous government that was convinced 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."

De la Madrid also launched a historic free-market transformation of Mexico's economy. He sold off about 750 of the 1,155 companies the government had owned when he took office and signed international free-trade treaties that paved the way for the North American Free Trade Agreement and helped Mexico develop into a global industrial power, although one overwhelmingly dependent on the United States.

Born on Dec. 12, 1934, to a prominent family in the western city of Colima, de la Madrid earned a degree from the National Autonomous University's law school, a spawning ground of Mexican politicians, and later earned a master's degree in public administration at Harvard University.

He began a rapid but unflashy climb through government agencies, serving in a series of finance-related posts before joining the Cabinet of President Jose Lopez Portillo as secretary of planning and programming in 1979.

Like all presidents to that time, Lopez Portillo was unchallenged master of the ruling Institutional Revolutionary Party, and the country as a whole. He chose de la Madrid, a 47-year-old bureaucrat who had never held elective office, as his successor and forced party activists who favored a more savvy politician to accept it.

In the pro-forma vote that followed, de la Madrid won more than 75 percent of the vote. It was the last time that the result of a Mexican presidential election could be seen as inevitable.

De la Madrid's lack of political experience sometimes cost him dearly. When big earthquakes hit on Sept. 19 and 20, 1985, devastated Mexico City residents ignored government appeals to stay in their homes and instead formed impromptu rescue brigades that rushed to collapsed buildings to save lives, with little official help. De la Madrid's scarce public appearances fed the public outrage.

The grass-roots aid groups that emerged from the quake helped energize a political opposition that was already growing because of economic woes.

Jeers and catcalls from frustrated Mexicans showered down on the president when he appeared at the World Cup soccer games Mexico hosted in 1986.

De la Madrid fumbled again when that opposition roused the strongest challenge yet to the party that had held an ironclad grip on Mexico for six decades. The 1988 presidential election bid by leftist Cuauhtemoc Cardenas was so strong the results were in doubt as the votes were being counted.

The government stopped reporting vote returns for a long period and then de la Madrid declared his own hand-picked successor Carlos Salinas the victor without formal results, leading many Mexicans to assume fraud had been committed. The ballots, never recounted, were burned three years afterward.

Anger over that election helped accelerate reforms that allowed an opposition party to finally win the presidency in 2000.

De la Madrid himself claimed some small share of credit for overseeing Mexico's move to democracy. Some early reforms came under his leadership, and he shocked party faithful when he predicted a time, "as Mexican society matures, when the opposition will share in the government."

But if Mexico's authoritarian system bent during his term, he did not break it. Opposition parties were allowed to win a few city mayoral races, but an ruling party victory for governorship of Baja California state was widely seen as fixed, and officials refused to accept clear opposition wins in some cities.

De la Madrid's main problems were rooted in the free-spending policies of Lopez Portillo, and a collapse in oil prices that left him with an economy that was spiraling rapidly downward, an inflation rate of more than 150 percent and an unpayable foreign debt of nearly $100 billion, more than half of the nation's gross domestic product at the time.

He raised taxes, cut the government budget, increased interest rates and imposed price and wage controls, while renegotiating debt conditions. Inflation dropped to about 50 percent.

The shrinking of the state also gave corrupt government officials fewer opportunities to squeeze private businessmen, and de la Madrid paired it with an a "moral renovation" anti-corruption campaign that reached its high point, at least in terms of publicity, with the arrest of the state oil company chief. Still, even de la Madrid's closest aides acknowledged the overall cleanup effort largely failed.

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

De la Madrid personally got along well 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 also 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.

For the most part, de la Madrid kept a low profile after leaving office, heading a state publishing company for several years.

He shook up Mexico's political class, however, when he gave a radio interview in 2009 accusing Salinas of stealing from a secret government fund and of turning a blind eye when his brother Raul Salinas profited from government contracts and contacts with drug traffickers.

De la Madrid retracted the allegations hours after they aired, claiming that because of his poor health he had been "weak and confused" in a radio interview with journalist Carmen Aristegui.

One of his five children, Enrique, has served in Mexico's congress and as director of the government farm finance bank, Financiera Rural. He also is survived by his wife, Paloma Cordero, and several grandchildren.