In a dramatic Sunday in Bolivia, President Evo Morales first offered to call new elections, and then chose to resign after the military called for him to step down. The events marked an escalation after weeks of violent protests that had mounted over his contested re-election last month.

Morales, 60, had led Bolivia since 2006, making him the longest-serving current head of state in Latin America. The country’s first indigenous leader, he oversaw an economic boom, a massive reduction in poverty and strides in social equality, earning him high approval ratings and three consecutive election wins.

But protesters accused Morales, a left-wing union leader and former coca farmer, of attempting to manipulate the results of the Oct. 20 national elections. He claimed to have won a fourth term outright, despite preliminary results indicating the need for a second round run off with his rightwing rival.

Thousands of Bolivians took to the streets, sometimes clashing violently with Morales’ political allies. Morales agreed to hold fresh elections after electoral observers refused to verify his victory, but in a crucial blow to the president, the country’s military chief joined calls for his resignation Sunday.

Morales has denied any wrongdoing and claims to be the victim of a “civic coup” organized by rightwing political forces and backed by the armed forces. But he said he was resigning to prevent further bloodshed, fulfilling his “obligation, as indigenous president and president of all Bolivians, to seek peace.” Here’s what to know about his resignation.

Who is Evo Morales?

Before Morales won his first election in 2005, Bolivia’s indigenous people — who make up at least 42% of the population according to the 2012 census (the government estimates it could be higher) — had struggled to win rights and representation from a political class dominated by wealthy families of European descent.

Morales, who hails from the large Aymara group, expanded freedoms for indigenous communities and legal protections for their cultures. He also delivered a sharp increase in living standards, improving access to electricity, sewerage and water services.

Economists say Morales responded to Latin America’s commodities boom more successfully than other governments in the region, marshalling Bolivia’s gas and mineral riches into fuel for both social programs and businesses. Bolivia remains South America’s poorest country after crisis-stricken Venezuela, but poverty fell from 60% in 2006 to 36% in 2017, while per capita GDP grew from $1,200 to over $3,350 in the same period.

But Morales’ relationship with the public began to sour in 2016, when he asked voters to approve the abolition of presidential term limits. Voters narrowly rejected Morales’ proposal. The president then turned to the constitutional court, dominated by his allies, which ruled that term limits violated human rights, paving the way for him to run for a fourth term this year. Since then critics have accused Morales of trying to turn Bolivia into an authoritarian state, also citing corruption scandals and the persecution of political opponents.

President of Bolivia Evo Morales Ayma speaks at press conference on November 10, 2019 in La Paz, Bolivia. Alexis Demarco –APG/Getty Images

Did Morales win the October election?

The live vote counting after national elections on Oct. 20 showed Morales in the lead, but just short of the 10 point lead he needed to win outright. The opposition celebrated the chance to go to a second round in December, in which their candidate, the right-wing former president Carlos Mesa, would have had a chance at unseating Morales.

But then Bolivia’s electoral board abruptly suspended the vote count for 24 hours. When it began again, the results showed Morales with 46.85% to Mesa’s 36.73%, just enough of a lead to avoid a run off. The opposition cried foul play — a claim now supported by the Organization of American States, whose observers reported “clear manipulations” of the voting system.

Morales’ critics immediately took to the streets in cities across the country, clashing with his supporters and the police. At least three people were killed in the protests and several hundred were injured. Local media also reported an arson attack on a government minister’s home and a brutal attack on a pro-Morales mayor in a small town in central Bolivia. Luis Fernando Camacho, a lawyer from the city of Santa Cruz who became the protests’ most visible leader, said Bolivians would remain in the street until Morales stepped down.

On Sunday, Williams Kaliman, the head of Bolivia’s armed forces backed protesters’ demands. “Given the escalating conflict the country is facing, and in order to secure the life and safety of the population, we suggest that the president resign his presidential mandate and allow the pacification and re-establishment of stability for the good of Bolivia,” he said at a press conference.

What will happen now that Morales has resigned?

After Morales announced his resignation in a televised address, thousands of his critics celebrated at rallies in the capital La Paz. Mesa, his opposition rival, announced the “end of tyranny” in Bolivia.

Late Sunday night, Morales tweeted that a police officer had publicly threatened him with an “illegal arrest warrant” and said “violent groups” had vandalized his home. A video circulating on social media and on Latin American news outlets claimed to show Bolivians wandering through Morales’ residence to survey the damage. Morales’ supporters have denounced his ousting as a rightwing coup.

The resignation now leaves a power vacuum in Bolivia. The vice-president and other top officials also stepped down amid the protests, including the senate and national assembly leaders that are mandated by Bolivia’s constitution to take up the presidency on an interim basis when it is empty. Though opposition senator Jeanine Añez has pledged to take up the job, that attempt would have to be approved by congress, where Morales’ Movement for Socialism party controls both houses. Per Bolivia’s constitution, an interim president would have to call fresh elections within 90 days.

Get The Brief. Sign up to receive the top stories you need to know right now. Please enter a valid email address. Sign Up Now Check the box if you do not wish to receive promotional offers via email from TIME. You can unsubscribe at any time. By signing up you are agreeing to our Terms of Use and Privacy Policy . This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Thank you! For your security, we've sent a confirmation email to the address you entered. Click the link to confirm your subscription and begin receiving our newsletters. If you don't get the confirmation within 10 minutes, please check your spam folder.

Write to Ciara Nugent at ciara.nugent@time.com.