Prime Minister KP Sharma Oli has resigned amid Nepal's worst unrest in decades as public anger mounts over the deaths of 19 anti-corruption protesters in clashes with police on Monday.

On Tuesday, crowds set fire to parliament in the capital Kathmandu, sending thick black smoke billowing into the sky. Government buildings and the houses of political leaders were attacked around the country.

Three more deaths were reported on Tuesday. Amid the chaos, jail officials said 900 inmates managed to escape from two prisons in Nepal's western districts.

The demonstrations were triggered by a ban on social media platforms. It was lifted on Monday - but by then, protests had swelled into a mass movement.

Nepal's army chief issued a statement late on Tuesday accusing demonstrators of taking advantage of the current crisis by damaging, looting, and setting fire to public and private property.

It 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.

While the prime minister has stepped down, it's not clear who will replace him or what happens next, with seemingly no one in charge. Some leaders, including ministers, have reportedly taken refuge with the security forces.

Inside parliament, there were jubilant scenes as hundreds of protesters danced and chanted slogans around a fire at the entrance to the building, many holding Nepal's flag. Some entered inside the building, where all the windows have been smashed. Graffiti and anti-government messages have been spray-painted on the exterior.

Kathmandu resident Muna Shreshta, 20, was among the large crowd outside parliament. She expressed the need for change, hoping it would be positive for the country.

Last week, Nepal's government ordered authorities to block 26 social media platforms for not complying with a deadline to register. The move was criticized as an attack on free speech.

Thousands of young people first attempted to storm the parliament building on Monday. Several districts were put under curfew. Most of the deaths occurred around parliament and government buildings on that day.

On Tuesday, protests continued unabated. A crowd in Kathmandu torched the headquarters of the Nepali Congress Party, which is part of the governing coalition, and the house of its leader, Sher Bahadur Deuba.

The house of KP Oli - a 73-year-old four-time prime minister who leads the Communist Party - was also set on fire. He stated that he had resigned to pave the way for a constitutional solution to the current crisis.

An aide to President Ramchandra Paudel told Reuters that the president had accepted the resignation and begun the process and discussions for a new leader.