Sri Lanka's President Gotabaya Rajapaksa will resign on Wednesday, the speaker of the parliament said, after thousands of protesters stormed his official residence and set the prime minister's private residence on fire in Colombo as anger intensified over the country's worst economic crisis in seven decades.

Prime Minister Ranil Wickremesinghe is willing to resign to make way for an all-party government, his office said in a statement, although it was not immediately clear if this or measures proposed by the parliamentary speaker would resolve the crisis.

Soldiers and police were unable to hold back a crowd of chanting protesters demanding Mr Rajapaksa's resignation, in a sharp escalation of months of anti-government protests over the dire economic situation.

The presidential palace was overrun by hundreds of people, with some treating themselves to a swim in the presidential pool

Inside the president's house, a Facebook livestream showed hundreds of protesters, some draped in the national flag, packing into rooms and corridors.

Video footage showed some of them splashing in the swimming pool, while others sat on a four-poster bed and sofas.

Some could be seen emptying out a chest of drawers in images that were widely circulated on social media.

Hundreds milled about in the grounds of the colonial-era whitewashed residence, with few security personnel in sight.

Mr Rajapaksa had left the official residence yesterday as a safety precaution ahead of the planned weekend demonstration, two defence ministry sources said. Reuters could not immediately confirm his whereabouts.

Protesters also broke into Mr Wickremesinghe's private residence and set it on fire, the prime minister's office said.

The prime minister had also been moved to a secure location, a government source told Reuters.

Fire at Mr Wickremesinghe's home

At least 39 people, including two police officers, were injured and hospitalised during the protests, hospital sources told Reuters.

Mr Wickremesinghe held talks with several political party leaders to decide what steps to take following the unrest.

Sri Lanka President Gotabaya Rajapaksa

"Wickremesinghe has told the party leaders that he is willing to resign as Prime Minister and make way for an all-party government to take over," his office said in a statement.

Parliament Speaker Mahinda Yapa Abeywardena said in a letter to Mr Rajapaksa that several decisions had been made at the meeting of leaders from parties - including the president and the prime minister resigning as soon as possible and parliament being called within seven days to select an acting president.

Ranil Wickremesinghe

"Under the acting president the present parliament can appoint a new prime minister and an interim government," said the letter released by the Speaker's office.

"Afterwards under a set time an election can be held for the people to elect a new parliament," it added.

Leaders of several opposition parties have also called for Mr Rajapaksa to resign.

"The president and the prime minister must resign immediately. If that does not happen political instability will worsen," said Sri Lanka Freedom Party leader and former president Maithripala Sirisena, speaking before Mr Wickremesinghe had offered his resignation.

Early in the day protesters forced their way through heavy metal gates into the Finance Ministry and the president's seafront offices and did not vacate the campus until late evening.

A local news channel said four journalists outside the prime minister's private home were assaulted during the protests.

The prime minister's office, in a statement, expressed "grave regret" over the assault on journalists by security personnel.

The Indian Ocean island of 22 million people is struggling under a severe foreign exchange shortage that has limited essential imports of fuel, food and medicine, plunging it into the worst economic crisis since independence in 1948.

Soaring inflation, which reached a record 54.6% in June and is expected to hit 70% in the coming months, has heaped hardship on the population.

Political instability could undermine Sri Lanka's talks with the International Monetary Fund as it seeks a $3 billion bailout, the restructuring of some foreign debt and fundraising from multilateral and bilateral sources to ease the dollar drought.

Police use a water canon to disperse demonstrators last night

The crisis comes after the Covid-19 pandemic hammered the tourism-reliant economy and slashed remittances from overseas workers.

It has been compounded by the build-up of hefty government debt, rising oil prices and a ban on the import of chemical fertilisers last year that devastated agriculture.

The fertiliser ban was reversed in November.

However, many blame the country's decline on economic mismanagement by Mr Rajapaksa and there have been months of largely peaceful protests demanding his resignation.

Before breaking into the government buildings, the protesters dismantled several police barricades in Colombo's government district.

Police fired shots in the air but were unable to stop the crowd from surrounding the presidential residence, a witness said.

Despite a severe shortage of fuel that has stalled transport services, demonstrators packed into buses, trains and trucks from several parts of the country to reach Colombo for the weekend demonstration.

Discontent has worsened in recent weeks as the cash-strapped country stopped receiving fuel shipments, forcing school closures and rationing of petrol and diesel for essential services.