Sri Lankan President Gotabaya Rajapaksa has fled the country and hundreds of protesters have stormed the prime minister’s office demanding his ouster, as an uprising over a devastating economic crisis overwhelmed security forces.

Rajapaksa called the speaker of parliament to say he would resign later on Wednesday and that his ally Prime Minister Ranil Wickremesinghe should be interim president, infuriating Sri Lankans struggling with months-long shortages of food, fuel and power.

The president’s flight brought an end to the rule of the powerful Rajapaksa clan that has dominated politics in the South Asian country for the last two decades.

Wickremesinghe’s office declared a state of emergency and a curfew with immediate effect, but then cancelled them. His office said the moves would be announced again later.

“Protesters have no reason to storm the prime minister’s office,” Wickremesinghe said in a statement.

“They want to stop the parliamentary process. But we must respect the Constitution. So security forces have advised me to impose an emergency and a curfew. I’m working to do that.”

Police stationed outside the prime minister’s office fired several rounds of tear gas and a military helicopter briefly circled overhead, but protesters appeared undeterred and finally surged into the compound. Wickremesinghe’s team declined to reveal his whereabouts.

In a video statement, the parliament speaker, Mahinda Yapa Abeywardena, said: “The president got in touch with me over the phone and said that he will ensure that his resignation letter will be received by me today.”

“I appeal to the public to have confidence in the parliamentary process we have outlined to appoint a new president on the 20th and be peaceful.”

Protests against the economic crisis came to a head last weekend when hundreds of thousands of people took over key government buildings in Colombo, blaming the Rajapaksas and their allies for runaway inflation, corruption and a severe lack of fuel and medicines.

Government sources and aides said the president’s brothers, former president and prime minister Mahinda Rajapaksa and former finance minister Basil Rajapaksa, were still in Sri Lanka.

Gotabaya Rajapaksa, his wife and two bodyguards left the main international airport near Colombo aboard a Sri Lankan Air Force plane early on Wednesday, the air force said in a statement.

A government source and a person close to Rajapaksa said he was in Male, the capital of the Maldives. The president would most likely proceed to another Asian country from there, the government source said.

Wickremesinghe, whose private residence in Colombo was set ablaze on Saturday, had offered to resign as prime minister but did not repeat that offer after he became acting president on Wednesday. If he does go, the speaker would be acting president until a new president is elected on July 20 as scheduled.

Protest leaders say the prime minister is allied to the Rajapaksas and have warned of a “decisive fight” if he does not resign.

The island nation’s tourism-dependent economy was hammered first by the COVID-19 pandemic and then suffered from a fall in remittances from overseas Sri Lankans. A ban on chemical fertilisers hit output although the ban was later reversed.

The Rajapaksas implemented populist tax cuts in 2019 that affected government finances while shrinking foreign reserves curtailed imports of fuel, food and medicines.

Petrol has been severely rationed and long lines have formed in front of shops selling cooking gas. Headline inflation hit 54.6 per cent last month and the central bank has warned that it could rise to 70 per cent in coming months.

Mahinda Rajapaksa resigned as prime minister in May after protests against the family turned violent. He remained in hiding at a military base in the east of the country for some days before returning to Colombo.

On Tuesday, Sri Lankan immigration officials prevented Basil Rajapaksa, who quit in April as finance minister and resigned his parliament seat in June, from flying out of the country.