Peru's attorney general resigned on Tuesday amid accusations that he hindered a corruption probe involving Brazilian construction giant Odebrecht.
In a letter presented to Peru's chief prosecutors, Pedro Chavarry said he was stepping down in order to preserve the autonomy of the Attorney General's Office and stop the country's president from intervening in other, independent branches of government.
Chavarry described himself as a "victim" of journalists, politicians and non-governmental organisations bent on having him removed from office and hounding him for performing his constitutional duties.
But his critics celebrated his resignation and described it as a move that would facilitate anti-corruption investigations in the South American country.
Chavarry had been appointed to the three-year position in July by a panel of senior prosecutors.
He often clashed with Peru's president and his tenure as Attorney General was marred by accusations that he was part of a ring of corrupt prosecutors who peddled political favours in exchange for bribes.
But Chavarry stayed in his post thanks to the support of two mayor opposition parties, whose leaders are currently being investigated for allegedly taking bribes from Odebrecht.
On New Year's Eve, Chavarry dismissed two popular prosecutors who led the Odebrecht corruption probe, accusing Jose Domingo Perez and Rafael Vela of blocking his request for information on the case. He also said Perez made public statements that put his objectivity in doubt.
But the dismissal sparked street protests in several cities in which demonstrators accused Chavarry of trying to protect corrupt officials and called for his resignation.
Peruvian President Martin Vizcarra said the removal of the prosecutors would derail the investigation and immediately pushed for an overhaul of the Attorney General's Office, calling on congress to declare that office in a state of emergency.
Faced with those threats, Chavarry reinstated the prosecutors.
But as investigators turned their attention toward the attorney general and raided the offices of one of his closest aides, Chavarry decided that he could no longer keep his job.
"If I am the pretext for these illegal actions to be taken against the institution I represent, then it is best for me to step aside," Chavarry wrote in his resignation letter.
Chavarry will be replaced by Zoraida Avalos, a seasoned prosecutor who has promised to clean up the Attorney General's office of corrupt officials, by declaring it in a state of emergency.
Odebrecht has admitted in US court filings that it paid $800m in bribes to officials across Latin America, including $29m in Peru.
- FOLLOW News24 on Twitter