Peru's President Pedro Pablo Kuczynski has quit over a vote-buying scandal.
He has denied wrongdoing but said on Wednesday that he did not want to be an obstacle to the country's development.
Party leaders in Congress later agreed to accept President Kuczynski's resignation. He had been facing an impeachment vote on Thursday.
Pressure has been growing after footage emerged of his allies offering opposition politicians financial rewards if they backed him in the vote.
Is he gone for good now?
Congress still has to vote on whether to accept President Kuczynski's resignation. Lawmakers will meet on Thursday to discuss the issue and are expected to put it to a vote later on Thursday or Friday.
Even before the vote-buying allegations emerged, a majority of lawmakers had indicated that they would vote in favour of his impeachment on grounds of him allegedly being "morally unfit" to hold office.
It is therefore hard to see how he could survive politically. In fact, members of Congress, especially his most bitter rivals, could still decide to plough ahead with the impeachment regardless of his offer to resign.
What exactly toppled him?
After months of allegations of corruption against Mr Kuczynski, what forced him to tender his resignation were highly damaging secretly filmed videos and audios.
They apparently show his allies trying to persuade members of Congress to back Mr Kuczynski in the impeachment vote which had been scheduled for Thursday.
In exchange, the members of Congress were offered lucrative public works projects for their constituencies.
The release of the recordings, just two days before the impeachment vote, piled on pressure on the already beleaguered president.
Lawmakers from his own party withdrew their support and Mr Kuczynski resigned on Wednesday.
What did he say?
President Kuczynski defended himself in a televised message, saying the video footage had been edited to incriminate him.
"The opposition has tried to paint me as a corrupt person and they have managed to influence a group of reasonable and honest workers around me, getting them unfairly involved in this plot to destroy the government," he said.
"I categorically reject these unsubstantiated claims and reaffirm my commitment to an honest, moral and fair Peru for everyone."
"I've worked for nearly 60 years of my life with complete honesty," the 79-year-old leader said. "Faced with this difficult situation... I think it is best for the country if I resign from the presidency of the republic.
"I don't want the country or my family to continue to suffer the uncertainty of recent times."
What uncertainty is he referring to?
Mr Kuczynski has already been through one impeachment vote. In December, his opponents wanted to remove him for allegedly receiving illegal payments from the Brazilian construction giant Odebrecht.
That time, he held onto power by a slim margin after Kenji Fujimori and a small number of other lawmakers broke away from the opposition to back him. But Mr Kuczynski's victory did not last long.
His decision just three days later to pardon Kenji Fujimori's father, former President Alberto Fujimori, was widely decried as a political deal, even though Mr Kuczynski insisted it was on humanitarian grounds.
It caused outrage among many Peruvians who believe Fujimori should stay in jail, where he was serving a lengthy sentence for authorising killings carried out by death squads.
In the wake of the pardon, President Kuczynski's approval rating fell from 26% in November to 19% in January, one poll suggested.
Members of Congress will vote on whether to accept Mr Kuczynski's resignation. According to the Peruvian Constitution, First Vice-President Martín Vizcarra will become acting president in his place.
Mr Vizcarra has said he is ready to put himself at the service of the country and is returning from Canada, where he was serving as Peru's ambassador. He could be sworn in as early as Friday.
A former governor of a mining-rich province, the 55-year-old is seen as business-friendly but some Peruvians have questioned whether he has the political experience to handle the presidency at a time of crisis.
Some lawmakers have already expressed their support for Mr Vizcarra to allow for an orderly transition, but Peru's Congress is deeply divided and it is not certain whether he will be able to unite lawmakers behind him for long.
To add to the pressure on the president-to-be, Peru will be hosting the Summit of the Americas in three week's time, which US President Donald Trump has said he will attend.
And what will happen to Mr Kuczynski?
Mr Kuczynski enjoys presidential immunity until Mr Vizcarra is sworn in. But with allegations of corruption against him mounting, he could face trial after he ceases to be president.
Mr Kuczynski has denied any wrongdoing and has promised to co-operate with an investigation into his connections to Odebrecht but prosecutors are taking no chances. On Wednesday, they asked asked a judge to bar Mr Kuczynski from leaving Peru.