Bolivian President Evo Morales has resigned amid turmoil following his disputed re-election last month.
On Sunday, international monitors called for the election result to be annulled, saying they had found “clear manipulations” of the 20 October poll.
Mr Morales agreed with the findings and announced his intention to call fresh elections – after overhauling the country’s election body.
But politicians – and the army and police chiefs – had urged him to quit.
In a televised address, Mr Morales said: “I resign my post as president.”
His Vice-President, Alvaro Garcia Linera, also resigned.
Protesters took to the streets to celebrate, chanting “yes we could” and setting off fire crackers.
How did we get here?
Bolivia has been rattled by weeks of anti-government protests, following reports of election fraud in the presidential election.
At least three people died during clashes. Some uniformed police officers also joined the protesters.
On Sunday, the Organization of American States (OAS), which monitored the elections, said it had found evidence of wide-scale data manipulation, and could not certify the result of the previous polls.
Pressure continued to build on Mr Morales during the day, as several of his political allies resigned, some citing fears for the safety of their families.
The army chief, General Williams Kaliman, also urged Mr Morales to resign “to allow for pacification and the maintaining of stability”.
The military also said it would conduct operations to “neutralise” any armed groups that attacked the protesters.
Mr Morales announced his resignation shortly afterwards, saying: “I ask you to stop attacking the brothers and sisters, stop burning and attacking.”