His death was announced by Andina, Peru’s state-run news agency. Mr. García shot himself early Wednesday as police officers arrived at his home in Lima to arrest him in connection with a corruption investigation, officials said.

Mr. García had allegedly received illegal payments from the Brazilian construction company Odebrecht, which in 2016 admitted in a plea agreement with the U.S. Justice Department that it had doled out nearly $800 million in bribes to Latin American officials in exchange for infrastructure contracts.

AD

AD

The case against Mr. García, part of the largest corruption investigation in Latin American history, centered on payments he allegedly received for the construction of the Lima Metro during his second term in office, from 2006 to 2011. In November, a Peruvian court barred him from leaving the country, and Mr. García unsuccessfully sought political asylum at the Embassy of Uruguay in Lima.

Although Mr. García denied receiving money from Odebrecht, the bribery investigation has snared politicians across the continent, most notably in Peru.

The country’s four most recent presidents are being investigated on corruption allegations — including former president Pedro Pablo Kuczynski, who was detained last week and was said to be hospitalized Wednesday with high blood pressure. A fifth, Alberto Fujimori, is serving a prison sentence for human rights violations and corruption unrelated to Odebrecht.

Standing more than 6 feet tall, with a youthful swagger and a speaking style that mixed Peruvian colloquialisms with quotes from Immanuel Kant and Shakespeare, Mr. García was a singular figure in South American politics, even in a region long known for the abrupt downfalls and subsequent resurrections of its presidents.

AD

AD

First elected president at 35, he railed against foreign investors and the International Monetary Fund, left office in disgrace and returned to power two decades later, reversing his economic positions with an emphasis on development.

“He’s always been seen as a very skillful, clever, silver-tongued kind of politician, able to avoid the moment of his arrest that happened today,” said Michael Shifter, president of the Washington-based Inter-American Dialogue.

Mr. García, he added, “presided over a complete economic disaster” before reinventing himself as “the darling of the neoliberals” in his second term. “What he did was continue an upward trajectory that started before him. He avoided making any major mistakes and just rode the wave.”

AD

Raised in a middle-class family, Alan Gabriel Ludwig García Pérez was born in Lima on May 23, 1949. He studied law in the capital, political science in Madrid and sociology at the Sorbonne in Paris before returning home and joining APRA, the center-left party formed by Víctor Raúl Haya de la Torre, Mr. García’s ideological lodestar.

AD

In 1978, Mr. García was elected to the Constituent Assembly, which devised a new constitution that paved the way for the country’s return to democratic elections after 12 years of military rule. He served in Congress starting in 1980 and drew comparisons to President John F. Kennedy before being elected president in 1985.

“As someone did once before,” he declared in his inaugural address, alluding to Kennedy, “I will say that I do not come to say what I will do, but rather to ask my people what they will do for their government, their destiny, for their justice and their liberty.”

AD

The government owed more than $13 billion to foreign creditors, and Mr. García acquired the stature of a folk hero when he announced that Peru would limit its interest payments, capping them at no more than 10 percent of export earnings.

AD

Early optimism surrounding his presidency soon gave way to chaos and upheaval. The government ran out of cash, the economy cratered and Mr. García was met with widespread protests when he proposed nationalizing the country’s banks, an initiative that ultimately failed and thrust novelist Mario Vargas Llosa into politics as an opposition leader.

As Mr. García announced an austerity plan to stanch the bleeding, inflation rates soared above 4,000 percent. Food lines stretched down city blocks, unemployment ran rampant and tens of thousands of workers went on strike to protest economic mismanagement.

AD

The cocaine industry boomed and Shining Path, a Maoist guerrilla movement, gained traction in the countryside. Mr. García was said to have given his military free rein to strike back, leading human rights observers to accuse him of presiding over a “dirty war” against leftists in the country. He also was criticized for his handling of 1986 prison riots that resulted in the massacre of several hundred guerrillas.

AD

Rumors swirled that a military coup might be in the works, and Mr. García was said to have twice submitted his resignation, only to be rebuffed by his vice president. Friends said he hoped to go down in a blaze of glory, like Chilean President Salvador Allende, and Peruvians gave him a nickname, Crazy Horse, for his erratic decision-making.

Mr. García made it through the end of his term, only to see his political fortunes fall even further. He was accused of embezzling government funds and taking kickbacks for fighter-jet purchases, and fled the country after his successor, Alberto Fujimori, instituted one-party rule and sought his arrest on corruption charges.

AD

He spent nine years in exile, living in Paris and writing books before returning to Peru in 2001. By then, Fujimori had resigned the presidency and fled to Japan, facing corruption and abuse of power scandals of his own, and the Supreme Court had ruled that the statute of limitations on Mr. García’s corruption charges had run out.

AD

His old political views had expired as well. Refashioning himself as a centrist, business-friendly politician, he narrowly lost the 2001 presidential race before being elected in 2006 with more than 50 percent of the vote, after tarring his opponent as a stooge of Venezuelan leader Hugo Chávez.

Voters reportedly viewed him as the lesser of two evils, describing the choice as “cancer versus AIDS,” according to a 2010 account in the New York Times, and Mr. García insisted he was a changed man. “Do you think I want my tombstone to read, ‘He was so stupid that he made the same mistakes twice’?” he said, according to the BBC.

AD

Mr. García trimmed the salaries of government workers and sold off assets, creating the largest Peruvian budget surplus in four decades, according to news reports. Buoyed by the rising price of copper, silver and gold, revenue soared, and his government launched infrastructure projects credited with bringing electricity to more than 900 towns.

AD

But his reputation was bruised by a 2009 clash between police and indigenous protesters, in which more than 30 were killed, and by presidential pardons of convicted drug traffickers. Some of them were found to have been freed in exchange for bribes.

Mr. García’s first marriage, to Carla Buscaglia, ended in divorce. He separated from his wife, Pilar Nores, in 2009 after Mr. García’s extramarital affair with American-born economist Roxanne Cheesman became public. He had a daughter from his first marriage, four children from his second marriage and a son from his affair. A complete list of survivors was not immediately available.

AD

At times, Mr. García seemed to believe he was being shortchanged by history — smeared by political opponents on corruption charges, and given too little credit for the economic growth during his second term.

AD

“We’re sort of still the kind of country that expects the son of the sun, the Inca, to do acts of magic,” he told the Times in 2010. “I have tried it, but it is difficult, almost impossible.”

When he ran for president one last time, in 2016, he received less than 6 percent of the vote, finishing fifth.