The speaker of Sri Lanka’s parliament has said President Gotabaya Rajapaksa has agreed to resign on Wednesday.

Mahinda Yapa Abeywardena said in a televised statement that he informed Mr Rajapaksa of a decision taken at a meeting of parliamentary party leaders requesting his resignation, and the President had agreed.

Mr Rajapaksa will remain as president until Wednesday to ensure a smooth transfer of power, Mr Abeywardena added.

Protesters in Colombo
A man throws back a tear gas canister after it was fired by police to disperse protesters in Colombo (AP)

The announcement came hours after protesters stormed the president’s official residence to vent their anger over the country’s severe economic crisis.

Protesters also broke into the Prime Minister Ranil Wickremesinghe’s private residence and set it on fire hours after he said he would resign.

It is not immediately clear if Mr Wickremesinghe was inside the Colombo residence at the time of the attack.

Mr Wickremesinghe’s earlier decision came after the biggest protest yet swept Sri Lanka on Saturday, with tens of thousands of people breaking through barricades and entering President Gotabaya Rajapaksa’s residence and nearby office to vent their fury against a leader they hold responsible for the nation’s worst economic crisis.

In his resignation pledge, Mr Wickremesinghe was responding to a call by leaders of political parties represented in parliament that he and Mr Rajapaksa should quit, after tens of thousands of people trooped to the capital to vent their fury at the leaders they hold responsible for the nation’s worst economic and political crisis.

Protests in Colombo
A man picks up a tear gas canister to throw it away after police fired it to disperse the protesters in Colombo (AP)

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

But he made it clear he will not step down before a new government is formed, angering crowds that moved near his home to force him to leave office immediately.

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

The president's residence
Protesters, many carrying Sri Lankan flags, gather outside the President’s office in Colombo (AP)

Mr Rajapaksa appointed Mr 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.

Many protesters accuse Mr Wickremesinghe of trying to save Mr Rajapaksa when he came under pressure to resign and every other member of his powerful political dynasty quit the cabinet.

Privately-owned Sirasa Television reported that at least six of their staff members including four reporters were taken to hospital after they were beaten by police while covering the protest near Mr Wickremesinghe’s home.

Sri Lanka water cannon
Police use water canon and tear gas to disperse the protesters in Colombo (AP)

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

The association said that the President, Prime Minister and the government would be held responsible if people died or were maimed.

It urged the leaders to heed the cry of the people, resign and hand over the reins to an all-party government.

Earlier on Saturday, the crowds broke into Mr Rajapaksa’s fortified residence. Footage showed people in a jubilant mood taking a dip in the garden pool of the residence.

Sri Lanka protests
Protesters, some holding Sri Lankan flags, gather in a street leading to the President’s official residence (AP)

Some lay on beds, others made tea and drank, and made “statements” from the conference room that Mr Rajapaksa and Mr Wickremesinghe must immediately quit.

It was not clear if Mr Rajapaksa was inside his residence when it was stormed. A government spokesman, Mohan Samaranayake, said he had no information about his movements.

Sri Lanka’s economy is in a state of collapse, relying on aid from India and other countries as its leaders try to negotiate a bailout with the International Monetary Fund.

The economic meltdown has led to severe shortages of essential items, leaving people struggling to buy food, fuel and other necessities.

The turmoil has led to months of protests, which have nearly dismantled the Rajapaksa political dynasty that has ruled Sri Lanka for most of the past two decades.