LIMA, Peru (AP) — Former Peruvian President Alan García died Wednesday after shooting himself in the head moments after police attempted to detain him amid corruption allegations in Latin America's largest graft probe.

President Martin Vizcarra announced on Twitter that García died after undergoing emergency surgery hours earlier. Doctors at the José Casimiro Ulloa Hospital in the capital city of Lima said they provided cardiac resuscitation three times while trying to save his life.

"Distraught over the death of ex-President Alan García," Vizcarra wrote. "I send my condolences to his family and loved ones."

The shocking end for the man who twice ruled Peru but more recently was ensnared in the Odebrecht corruption scandal comes amid national upheaval over endemic corruption involving nearly every former living president.

García repeatedly professed his innocence and said he was the victim of false testimony by political enemies who accused him of taking more than $100,000 from the Brazilian construction giant. Odebrecht admitted in a 2016 plea agreement with the U.S. Justice Department that it paid nearly $800 million throughout Latin America in exchange for lucrative public works contracts.

The 69-year-old former head of state's attorney accused authorities Wednesday of neglecting to provide García information on why he was being detained or show their official identifications when they showed up to arrest him.

"The president, upset over this situation, knowing his absolute innocence ... had this terrible accident," attorney Erasmo Reyna said.

Interior Minister Carlos Morán said police found García on the second floor of his home when they arrived. He asked for a moment to call his lawyer, entering a bedroom of the leafy mansion in Miraflores and closing the door behind him.

"Minutes later the sound of gunfire was heard," Morán said. "Police forced their way into the room and found him."

He was immediately transported to the hospital, arriving at 6:45 a.m. local time. A team of doctors, some called from outside hospitals, began operating at 7:10 a.m., according to Peru's health ministry.

"The situation is very critical," Health Minister Zulema Tomás said shortly after the incident. "It's grave."

The stunning turn of events comes four months after García tried to seek asylum in Uruguay as prosecutors in Peru investigated allegations he illegally took payments from Odebrecht. He remained there for a little more than two weeks before having his request denied. In rejecting his claim, the South American nation's embassy said there was no evidence to support García's contention that he was being targeted politically.

"In Peru, the three branches of government function freely and autonomously, especially in the case of judicial power," Uruguayan President Tabaré Vázquez said.

Peru has gone further than any other country outside Brazil in prosecuting politicians tied to the Odebrecht probe. All but one living former head of state is being investigated for corruption tied to the scandal.

Just last week, former President Pedro Pablo Kuczynski was also detained for alleged money laundering tied to the probe. Congressional allies said he was taken Tuesday night to a local clinic with high blood pressure.

On Wednesday, Alberto Quintanilla, a congressman from the left-leaning political party Nuevo Peru, expressed solidarity with the family of García and said that he hoped officials "would advance knowledge of the truth" through their investigations, but also respect due process.

García was a populist firebrand whose erratic first presidency in the 1980s was marked by hyperinflation, rampant corruption and the rise of the Shining Path guerrilla movement.

When he returned to power two decades later he ran a more conservative government, helping usher in a commodities-led investment boom in which Odebrecht played a major supporting role.

A judicial order obtained by The Associated Press shows Judge Juan Sanchez ordered authorities to arrest García and search for documents in his home related to money laundering allegations.

Prosecutors suspect the former president received more than $100,000 from Odebrecht, disguised as a payment to speak at a conference in Brazil.

More From KTEM-AM