Bolivian President Evo Morales has resigned after nearly 14 years in power, amid turmoil following his disputed re-election last month.
The head of the army had called on him to go after protests over his election win.
Auditors found irregularities with the poll but Mr Morales said he had been the victim of a coup.
He said he was leaving to help protect families of political allies, after their homes were burned down.
In a televised address, Mr Morales urged protesters to "stop attacking the brothers and sisters, stop burning and attacking".
The biggest criticism of Evo Morales was his lack of respect for Bolivia's democracy - accused of overstaying his welcome and refusing to step down.
But the fact that the military has called the shots on the president standing down does not do much for Bolivia's democracy either.
Now Evo Morales has gone, there is a power vacuum. Increasing numbers of his Mas party are resigning, and it feels like there is a need for retribution - for Evo Morales and his people to pay the price for the mistakes they made while in power.
His supporters have called this a coup - his detractors the end of tyranny. The priority now is to choose an interim leader, call new elections and bring a polarised Bolivia together or face yet more unrest and violence in the coming weeks.
Vice-President Alvaro García and Senate President Adriana Salvatierra also resigned.
Protesters took to the streets to celebrate, chanting "yes we could" and setting off fire crackers.
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.
Media captionWatch how police took part in Bolivia's anti-government protests on Saturday
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, Gen Williams Kaliman, 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.
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!"
Protesters chanted "yes we could" and "Bolivia" as they celebrated the resignation
However, the Cuban and Venezuelan leaders - who had previously voiced their support for Mr Morales - condemned the events as a "coup".
Cuban President Miguel Díaz-Canel described it as a "violent and cowardly" attempt against democracy, while Venezuelan leader Nicolás Maduro said tweeted: "We categorically condemn the coup realised against our brother president."
Mexico says it is considering granting asylum to Mr Morales.
Bolivia's first indigenous president, he 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.