COLOMBO, Sri Lanka (AP) — Protesters retreated from government buildings Thursday in Sri Lanka, restoring a tenuous calm to the economically crippled country, and the embattled president at last emailed the resignation that demonstrators have sought for months.

President Gotabaya Rajapaksa fled a day earlier under pressure from protesters enraged by the island nation’s economic collapse. He emailed his resignation a day later than promised, according to an official.

But with a fractured opposition and confusion over who is in charge, a solution to the country’s many woes seemed no closer following Rajapaksa’s departure. And the president has further angered the crowds by making his prime minister the acting leader.

Protesters have pressed for both men to leave and for a unity government to address the economic calamity that has triggered widespread shortages of food, fuel and other necessities.

The tentative way the resignation unfolded only added to turmoil. An aide to the speaker of the Sri Lankan Parliament issued a statement that said the speaker had received the president’s resignation through the Sri Lankan Embassy in Singapore, but there was no immediate official announcement.

An announcement was planned for Friday after the authenticity and legality of the letter are verified, the statement said.

As word of the resignation spread, jubilant crowds gathered near the president’s office to celebrate. Dozens of people danced and cheered and waved the Sri Lankan flag, and two men sang in Sinhalese on a small stage.

The mood was festive, with people hooting and swaying to music while others chanted into a microphone that they wanted better governance.

“To be validated like this is massive,” said Viraga Perera, an engineer who has been protesting since April. “On a global scale, we have led a movement that toppled a president with minimal force and violence. It’s a mix of victory and relief.”

The protesters accuse Rajapaksa and his powerful political family of siphoning money from government coffers for years and his administration of hastening the country’s collapse by mismanaging the economy. The family has denied the corruption allegations, but Rajapaksa acknowledged that some of his policies contributed to the meltdown.

Months of protests reached a frenzied peak over the weekend when demonstrators stormed the president’s home and office and the official residence of Prime Minister Ranil Wickremesinghe. On Wednesday, they seized Wickremesinghe’s office.

Images of protesters inside the buildings — lounging on elegant sofas and beds, posing at officials’ desks and touring the opulent settings — captured the world’s attention.

They initially vowed to hold those places until a new government was in place, but the movement shifted tactics Thursday, apparently concerned that any escalation in violence could undermine their message following clashes the previous night outside the Parliament that left dozens injured.

“The fear was that there could be a crack in the trust they held for the struggle,” said Nuzly, a protest leader who goes by only one name. “We’ve shown what power of the people can do, but it doesn’t mean we have to occupy these places.”

Devinda Kodagode, another protest leader, told The Associated Press they planned to vacate official buildings after Parliament Speaker Mahinda Yapa Abeywardana said he was exploring legal options for the country in the wake of Rajapaksa’s departure.

Visaka Jayaweer, a performing artist, described the bittersweet moment of closing the gate to the presidential palace after the crowds cleared out.

“Taking over his residence was a great moment. It showed just how much we wanted him to step down. But it is also a great relief” to leave, she said. “We were worried if people would act out — many were angry to see the luxury he had been living in when they were outside, struggling to buy milk for their children.”

The country remains a powder keg, and the military warned Thursday that it had powers to respond in case of chaos — a message some found concerning.

Troops in green uniforms and camouflage vests arrived in armored vehicles to reinforce barricades around the Parliament, while protesters vowed to continue holding rallies outside the president’s office until a new government was in place.

The government announced another curfew in the capital of Colombo and its suburbs until early Friday. Some people ignored a previous curfew, but many others rarely leave their homes anyway because of fuel shortages.

Rajapaksa and his wife fled Sri Lanka early Wednesday for the Maldives, slipping away in the night aboard a military plane. On Thursday, he went to Singapore, according to the city-state’s Foreign Ministry. It said he had not requested asylum.

Since Sri Lankan presidents are protected from arrest while in power it’s likely Rajapaksa wanted to plan his departure while he still had constitutional immunity and access to the plane.

The protests underscored the dramatic fall of the Rajapaksa political clan that has ruled Sri Lanka for most of the past two decades.

As a military strategist whose brutal campaign helped end the country’s 26-year civil war, Gotabaya Rajapaksa and his brother, who was president at the time, were hailed by the island’s Buddhist Sinhalese majority. Despite accusations of wartime atrocities, including ordering military attacks on ethnic Tamil civilians and abducting journalists, Rajapaksa remained popular among many Sri Lankans. He has continually denied the allegations.

The shortages of basic necessities have sown despair among Sri Lanka’s 22 million people. The country’s rapid decline was all the more shocking because, before the recent crisis, the economy had been expanding, with a growing, comfortable middle class.

It was not immediately clear if Singapore would be Rajapaksa’s final destination, but he has previously sought medical care there, including undergoing heart surgery.

Sri Lankan lawmakers have agreed to elect a new president from their ranks on July 20 who will serve the remainder of Rajapaksa’s term, which ends in 2024. That person could potentially appoint a new prime minister, who would then have to be approved by Parliament.

___

Associated Press writer Bharatha Mallawarachi contributed to this report.

___

Find more of AP’s Sri Lanka coverage at https://apnews.com/hub/sri-lanka