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.
Some of his allies were attacked earlier this week, and said their homes had been set alight.
In a televised address, Mr Morales said he would resign as president, and urged protesters to "stop attacking the brothers and sisters, stop burning and attacking".
The Vice-President, Alvaro Garcia Linera, and Senate President Adriana Salvatierra, have 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 the reports of election fraud.
Tensions first flared on the night of the presidential election after the results count was inexplicably stopped for 24 hours. The final result gave Mr Morales slightly more than the 10-percentage-point lead he needed to win outright in the first round of the race.
At least three people died during clashes that followed. Some uniformed police officers also joined the protesters.
On Sunday, the Organization of American States, 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.
What reaction has there been?
Opposition leader Carlos Mesa - who came second in last month's poll - thanked protesters for "the heroism of peaceful resistance". In a tweet, he described the development as "the end of tyranny" and a "historical lesson", saying, "Long live Bolivia!"
However, the Cuban and Venezuelan leaders - who had previously voiced their support for Mr Morales - condemned the events as a "coup".
Cuban President Miguel Diaz-Canel described it as a "violent and cowardly" attempt against democracy, while Venezuelan leader Nicolas Maduro said tweeted: "We categorically condemn the coup realised against our brother president."
Who is Evo Morales?
Mr Morales, who was Bolivia's first indigenous president, had served as leader since 2006.
He ran for a fourth consecutive term in the October elections after a controversial decision by the constitutional court to scrap presidential term limits.
In a 2016 referendum, a majority had voted "no" to dropping the limit of term numbers that Bolivians could serve. However, Mr Morales' party took the issue to the constitutional court, which abolished the term limits altogether.