Bolivian President Evo Morales has resigned amid deepening unrest over allegations of electoral fraud.
The announcement came after the country's military chief called for him to step down.
Mr Morales has endured weeks of violent protests since his election victory last month was called into question, with the Organization of American States later saying there was "clear manipulation" at the polls.
Three people have been killed and more than 100 injured in clashes between supporters and opponents of the president.
Protesters have also set fire to the headquarters of local electoral offices and set up roadblocks that paralysed parts of the country.
Mr Morales said in televised comments on Sunday that he would submit his resignation letter to restore stability, but claimed there had been a "civic coup."
"I am sending my resignation letter to the Legislative Assembly of Bolivia," he said, adding: "I ask you to stop attacking the brothers and sisters, stop burning and attacking."
Concerns were initially raised about a day-long gap in reporting results from the 20 October election, just before a spike in votes for Mr Morales.
Mr Morales, who came to power in 2006, had promised a fresh vote and was also South America's longest-serving leader.
But the intervention of General Williams Kaliman appears to have forced him to go.
"After analysing the situation of internal conflict, we ask the president to resign, allowing peace to be restored and stability to be maintained for the good of our Bolivia," said the military chief.
The European Union, the US, Brazil and the United Nations have all raised concerns about the election.
Former president Carlos Mesa, who was running against Mr Morales, called the result "a monumental fraud".
Mr Morales, 60, was Bolivia's first president from its indigenous population and helped lead an upturn in the country's economy after he was first elected.
However, his bid for a fourth term as leader came after he refused to follow the results of a 2016 referendum supporting a limit on how long a president can serve.