Thousands of protesters in Sri Lanka have broken through police barricades and stormed the president’s official residence.

In one of the biggest anti-government marches to hit the country this year as the economy crumbles, the demonstrators have demanded the resignation of President Gotabaya Rajapaksa.

The prime minister, Ranil Wickremesinghe, announced he would quit on Saturday afternoon.

“To ensure the continuation of the government including the safety of all citizens I accept the best recommendation of the party leaders today, to make way for an all-party government,” he tweeted.

He stepped down after thousands of people descended on the government district in Sri Lanka‘s capital Colombo, shouting slogans against the president and dismantling several police barricades to reach his house.

Police fired shots in the air but were unable to stop the angry crowd from surrounding the residence.

At least 39 people including two police officers have now been hurt by the unrest, hospital sources said.

More on Sri Lanka

Protesters also assembled outside the Presidential Secretariat – the office of the president – and the home of prime minister.

Both Mr Rajapaksa and Mr Wickremesinghe have both been moved to a secure location as a safety precaution, defence ministry sources said.

Hundreds of flag-bearing protesters packed inside the president’s sea-front property and used the swimming pool on a Facebook livestream.

Mr Wickremesinghe, who was appointed in May, resigned after summoning political party leaders for an emergency meeting in the wake of the violence.

He also requested parliament to be recalled by the speaker, a statement from his office said.

US ambassador to Sri Lanka Julie Chung called on people to protest peacefully and for police to give demonstrators space – as she warned “chaos and force will not fix the economy”.

Sri Lanka, home to 22 million people, is facing its worst economic crisis in seven decades since it achieved independence in 1948.

Inflation hit a record 54.6% in June and is expected to soar to 70%, piling pressure on the cash-strapped population.

The country has been struggling under a severe foreign exchange shortage that has limited essential imports of fuel, food and medicine.

Many blame the decline on Mr Rajapaksa, who has faced ongoing calls to resign.

Protester Sampath Perera, 37, criticised the president for “clinging on to power” and warned: “We will not stop until he listens to us.”

Anger intensified in recent weeks as fuel shipments dwindled, leading to petrol and diesel being rationed for essential services.

The British Foreign Office has warned against all but essential travel to the country, which has been left in financial turmoil due to economic mismanagement and the impact of the pandemic.

In April this year, Sri Lanka announced it was suspending repayment of foreign loans, blaming a foreign currency shortage.

It has accumulated debts of £42.4billion – of which around half, £23.3bn, must be repaid by the end of 2027.

The crisis has severely dented the reputation of the Rajapaksa political dynasty, which has led the country for most of the past two decades.

Mr Rajapaksa has so far held on to power after his brother resigned as prime minister in May and two other brothers and a nephew quit their cabinet posts earlier this year.