Photo/Illutration Protesters, many carrying Sri Lankan flags, gather outside the presidents office in Colombo, Sri Lanka, July 9, 2022. (AP Photo)

COLOMBO, Sri Lanka — Sri Lanka’s president and prime minister agreed to resign Saturday after the country’s most chaotic day in months of political turmoil, with protesters storming both officials’ homes and setting fire to one of the buildings in a rage over the nation's severe economic crisis.

Prime Minister Ranil Wickremesinghe said he will leave office once a new government is in place, and hours later the speaker of Parliament said President Gotabaya Rajapaksa would step down Wednesday. Pressure on both men grew as the economic meltdown set off acute shortages of essential items, leaving people struggling to buy food, fuel and other necessities.

Police had attempted to thwart promised protests with a curfew, then lifted it as lawyers and opposition politicians denounced it as illegal. Thousands of protesters entered the capital, Colombo, and swarmed into Rajapaksa’s fortified residence. Video images showed jubilant crowds splashing in the garden pool, lying on beds and using their cellphone cameras to capture the moment. Some made tea, while others issued statements from a conference room demanding that the president and prime minister go.

It was not clear if Rajapaksa was there at the time, and government spokesman Mohan Samaranayake said he had no information about the president’s movements.

Protesters later broke into the prime minister’s private residence and set it on fire, Wickremesinghe’s office said. It wasn’t immediately clear if he was there when the incursion happened.

Earlier, police fired tear gas at protesters who gathered in the streets to march on the presidential residence, waving flags, banging drums and chanting slogans. In all, more than 30 people were hurt in Saturday's chaos.

Speaker Mahinda Yapa Abeywardena said in a televised statement that he informed Rajapaksa that parliamentary leaders had met and decided to request he leave office, and the president agreed. However, Rajapaksa will remain temporarily to ensure a smooth transfer of power, Abeywardena added.

“He asked me to inform the country that he will make his resignation on Wednesday the 13th, because there is a need to hand over power peacefully,” Abeywardena said.

“Therefore there is no need for further disturbances in the country, and I urge everyone for the sake of the country to maintain peace to enable a smooth transition,” the speaker continued.

Opposition lawmaker Rauff Hakeem said a consensus was reached for the speaker of Parliament to take over as temporary president and work on an interim government.

Wickremesinghe announced his own impending resignation but said he would not step down until a new government is formed, angering protesters who demanded his immediate departure.

“Today in this country we have a fuel crisis, a food shortage, we have the head of the World Food Program coming here and we have several matters to discuss with the IMF,” Wickremesinghe said. “Therefore, if this government leaves there should be another government.”

Wickremesinghe said he suggested to the president to have an all-party government, but did not say anything about Rajapaksa’s whereabouts. Opposition parties were discussing the formation of a new government.

Rajapaksa appointed Wickremesinghe as prime minister in May in the hope that the career politician would use his diplomacy and contacts to resuscitate a collapsed economy. But people’s patience wore thin as shortages of fuel, medicine and cooking gas only increased and oil reserves ran dry. Authorities have also temporarily shuttered schools.

The country is relying on aid from India and other nations as leaders try to negotiate a bailout with the International Monetary Fund. Wickremesinghe said recently that negotiations with the IMF were complex because Sri Lanka was now a bankrupt state.

Sri Lanka announced in April that it was suspending repayment of foreign loans due to a foreign currency shortage. Its total foreign debt amounts to $51 billion, of which it must repay $28 billion by the end of 2027.

Months of demonstrations have all but dismantled the Rajapaksa political dynasty, which has ruled Sri Lanka for most of the past two decades but is accused by protesters of mismanagement and corruption. The president’s older brother resigned as prime minister in May after violent protests saw him seek safety at a naval base.

With fuel costs making other forms of travel impossible for many, protesters crowded onto buses and trains Saturday to get to the capital, while others made their way on bicycles and on foot. At the president’s seaside office, security personnel tried in vain to stop protesters who pushed through fences to run across the lawns and inside the colonial-era building.

At least 34 people including two police officers were hurt in scuffles. Two were in critical condition, while others sustained minor injuries, according to an official at the Colombo National Hospital who spoke on condition of anonymity as he was not authorized to talk to the media.

Privately owned Sirasa Television said at least six of its workers, including four reporters, were hospitalized after being beaten by police while covering the protest at the prime minister’s home.

Sri Lanka Medical Council, the country’s top professional body, warned that hospitals were running with minimum resources and would not be able to handle any mass casualties from the unrest.

Protest and religious leaders said Rajapaksa has lost his mandate and it is time for him to go.

“His claim that he was voted in by the Sinhala Buddhists is not valid now,” said Omalpe Sobitha, a prominent Buddhist leader. He urged Parliament to convene immediately to select an interim president.