Prime Minister KP Sharma Oli resigned on Tuesday as mass anti-corruption protests that began over a government ban on social media swept through the capital and other parts of Nepal, leaving at least 22 people dead and the parliament building in Kathmandu set on fire.

Crowds stormed the area around the federal legislature, setting a fire at the building’s entrance and smashing windows, while demonstrators torched the headquarters of the ruling Nepali Congress party and the homes of senior leaders, including Sher Bahadur Deuba and Mr. Oli. Security officials reported three more deaths on Tuesday, bringing the total to 22 after 19 people were killed in clashes with police on Monday.

The violence has spread beyond Kathmandu. Government buildings and private property were attacked in multiple districts, and jail officials said about 900 inmates escaped from two prisons in western Nepal amid the chaos. Some cabinet ministers and other political figures were reported to have taken refuge with security forces as order broke down.

In his resignation letter to President Ramchandra Paudel, Oli said he stepped down "to facilitate the solution to the problem and to help resolve it politically in accordance with the constitution." An aide to the president told Reuters that the resignation had been accepted and that discussions had begun on selecting a new leader.

The demonstrations began after the government ordered the blocking of 26 social media platforms for failing to comply with a deadline to register, a move officials said was aimed at combating fake news, hate speech and online fraud. Platforms such as Facebook and Instagram have millions of users in Nepal and are widely used for news, commerce and social interaction. Although the ban was lifted late on Monday following an emergency government meeting that officials said aimed to "address the demands of Gen Z," the protests had by then swelled into a broader mass movement targeted at the political elite and alleged corruption.

The protests appeared largely spontaneous and leaderless, driven in part by an online "nepo kid" campaign that spotlighted the lifestyles and privileges of politicians' children and amplified accusations of graft. Thousands of young people attempted to storm parliament on Monday; curfews were imposed in several districts as police and protesters clashed outside government buildings.

Inside the parliament complex on Tuesday, hundreds of demonstrators danced and chanted around a blaze at the entrance, with some entering the building. Graffiti and anti-government slogans covered the exterior. A 20-year-old Kathmandu resident, Muna Shreshta, told the BBC that longstanding corruption was the catalyst for her and others, saying it was "high time our nation, our prime minister, and anyone in power changes."

The Nepal Army’s chief issued a statement late on Tuesday accusing demonstrators of taking advantage of the crisis to damage, loot and set fire to public and private property. The statement said if unrest continued, "all security institutions, including the Nepal Army, are committed to taking control of the situation," effective from 22:00 local time (16:15 GMT; 17:15 BST), without specifying the measures that might follow.

Officials said most of the casualties occurred around parliament and government buildings during Monday’s confrontations. The full toll and an exact account of events across districts remained unclear as authorities struggled to re-establish control and restore public order.

With the prime minister’s resignation, Nepal faces immediate political uncertainty. The constitution sets out procedures for forming a new government, but it was not immediately clear who would command enough support to succeed Oli amid a crisis that has eroded public confidence in the political class. The president’s office said it had begun consultations on a successor.

International and domestic observers said the unrest highlights deep-rooted grievances over corruption, governance and youth marginalization in a country that has experienced frequent political upheaval since its transition from monarchy to republic. For now, the situation remains fluid, with the security forces and political leaders under pressure to restore order while addressing the grievances that have driven thousands of Nepalese into the streets.