Zimbabwe’s embattled President Robert Mugabe abruptly resigned Tuesday, bringing a potentially peaceful end to a growing political crisis that had raised fears of a military crackdown or other violence.

Mugabe’s resignation was announced by the speaker of the country’s parliament, Jacob Mudenda. The BBC reported that Mugabe, 93, released a letter saying he’d made the decision to avoid further unrest and pave the way for a smoother transition of power in the country he’d ruled singlehandedly since it gained its independence in 1980.

The move could bring a rapid end to a crisis that was triggered when the country’s military ousted Mugabe in a bloodless coup last week.

It also came just two days after the ruling ZANU-PF party voted to remove Mugabe as president and head of the party and appointed his former Vice President Emmerson Mnangagwa to succeed him. Mugabe appeared on state television later that night to deliver what many believed would be his formal resignation speech. Instead, the aging leader talked about healing divisions in the country and said nothing about stepping down.

The Zimbabwean parliament responded by opening impeachment proceedings against Mugabe, a process that will now end given his resignation.

In a clear sign of just how much Mugabe’s fortunes had fallen, the BBC said members of parliament cheered when the resignation was announced, and that there were scenes of Zimbabweans dancing in the streets in the capital city of Harare.

The former president wasn’t the only member of the Mugabe family facing political pressure. ZANU-PF members had also ousted Zimbabwe’s controversial first lady Grace Mugabe, who many believed was poised to become her husband’s successor.

Robert #Mugabe has been dismissed as leader of the ruling ZANU-PF party in #Zimbabwe, Reuters sources say pic.twitter.com/ydLwFYxwjn — Sky News (@SkyNews) November 19, 2017

The crisis in Zimbabwe had looked liked it was about to get even worse

Sunday’s vote came about two weeks after Mugabe fired Mnangagwa, which led to tanks rolling through the streets of Harare while military leaders took over Zimbabwe’s state television and placed Mugabe under house arrest.

Underlying all of this is a power struggle between the Mugabe family and Mnangagwa, who has plenty of military allies. As vice president, Mnangagwa was supposed to be next in line for the presidency. But there was increased speculation that the spot would go to Grace Mugabe, a controversial figure with few friends in the military or the ruling party.

Grace Mugabe has not appeared in public since Wednesday, the New York Times reported.

Mugabe had been in power for 37 years. He became prime minister in 1980, the same year Zimbabwe gained independence from Great Britain. The country was once called the “breadbasket” of the region, but under Mugabe’s rule, Zimbabwe’s economy has declined sharply, in large part due to corruption and government mismanagement.

It’s clear Zimbabwe’s citizens want Mugabe out, but there’s still a lot of uncertainty about the country’s future and whether Mnangagwa or the military represents a real change. Nicknamed the “Crocodile,” the former vice president is widely seen as another ruthless strongman. That’s because he helped carry out many of Mugabe’s policies over the years and participated in a bloody crackdown on a minority ethic group in 1980.

“There is a healthy dose of trepidation because they know that the man who might take over is not Mr. Democracy,” Wilf Mbanga, editor of the online newspaper the Zimbabwean, told the New York Times. “His track record is not impressive. He’s got a messy past. Is he going to clean his act? We don’t know.”