KATHMANDU, Nepal — Armed soldiers guarded major streets of the capital Wednesday and ordered residents to stay home as authorities sought to restore order following days of violent demonstrations that saw tens of thousands of people storm government buildings, set fires and attack political leaders.

Soldiers conducting vehicle and identity checks patrolled key areas of Kathmandu after the army, which rarely is mobilized, issued a statement late Tuesday saying security forces were committed to preserving law and order. The military said 21 suspected looters had been arrested as troops enforced a curfew that officials urged residents to observe.

The unrest intensified Tuesday after police opened fire on crowds that had gathered to protest a government-ordered block on several social media platforms, killing 19 people and wounding scores, according to officials and reports. The social media restrictions were lifted Tuesday, but demonstrations continued, fueled by anger over the fatalities and broader grievances including allegations of political corruption and economic frustration among young Nepalis.

President Ram Chandra Poudel accepted the resignation of Prime Minister Khadga Prasad Oli and named him to lead a caretaker government, though it was unclear what authority Oli would have or where he would be based amid the upheaval. Army helicopters ferried some ministers to secure locations as protesters stormed the parliament, the presidential house, the central secretariat that houses key ministries, and the prime minister’s official residence.

Smoke was reported rising from the parliamentary and presidential compounds and from the central secretariat on Wednesday. The building of Kantipur, Nepal’s largest media outlet, was torched and damaged, and several car showrooms and other businesses were set ablaze. Burned-out vehicles littered some streets as demonstrators blocked roads and forced closures across the city.

Video shared on social media showed members of the crowd assaulting Nepali Congress party leader Sher Bahadur Deuba and his wife, Arzu Rana Deuba, who is the foreign minister. Both appeared to be bleeding in the footage. The Nepali Congress is the country’s largest party and a member of the governing coalition.

The demonstrations, which participants and some media have described as the "protest of Gen Z," began after the government moved to block about two dozen social networks that did not comply with a registration requirement intended to force platforms to appoint local points of contact. Officials say the step was part of a bill aimed at regulating social media to ensure the platforms are "properly managed, responsible and accountable." Rights groups have criticized the proposal as an attempt to curb freedom of expression and silence government critics.

Protesters have voiced broader grievances tied to economic opportunity and perceptions of elite privilege. Youth unemployment in Nepal was about 20% last year, according to the World Bank, and authorities estimate more than 2,000 young Nepalis leave the country each day seeking work abroad in the Middle East or Southeast Asia.

Prime Minister Oli ordered an investigation into the shootings and pledged compensation for victims’ families, officials said. Police had faced heavy criticism for opening fire on demonstrators, an action that appeared to escalate already volatile protests.

As troops guarded central Kathmandu on Wednesday, authorities urged calm and adherence to the curfew. Tens of thousands of protesters remained active in the streets earlier in the week, and the situation was fluid as security forces worked to regain control and political leaders sought to respond to demands sparked by the social media restrictions and underlying social and economic frustrations.