Nepal’s army moved into the capital and restored a measure of order after two days of deadly street violence that left Parliament, the Supreme Court and the president’s house burned and 34 people dead, but the military now faces a fraught and unclear political role.

Angry protests that began over a short-lived social media ban and broader discontent toppled Prime Minister Khadga Prasad Oli and prompted chaos across Kathmandu that resembled a war zone. The situation began to calm after Gen. Ashok Raj Sigdel, the Nepal army chief, appeared in a prerecorded video appeal for calm and soldiers were deployed across the city to secure key sites, quell a jail break in the heart of the capital and open talks with protesters.

Five days after the unrest began, confusion persisted over who will take control of the government. President Ram Chandra Poudel, whose role is largely ceremonial under Nepal’s 2015 constitution, had asked Oli to head a caretaker government, but Oli fled his official residence and his whereabouts remained unclear. Army commanders, the president and representatives of protest groups held meetings to seek a name for an interim leader, but no consensus had been reached and the constitution provides no mechanism for naming an interim executive.

The army’s intervention was widely welcomed by residents who said police had failed to contain the chaos. “When the police failed to control chaos in the country, the army stepped in right on time and saved the country from plunging into a state of lawlessness,” said Ramesh Shrestha, a car mechanic in Kathmandu. Some protesters angered by police actions also praised the military for helping bring calm. “Nepal’s army is known for its peacekeeping roles internationally and it has brought peace inside the country too,” said student Kabita Yadav.

The military in Nepal has historically been popular and is not generally seen as a political actor. It has been mobilized mainly for disaster response — floods, landslides and earthquake rescues — and has contributed more troops to United Nations peacekeeping missions than any other country in recent years. Nepali forces also fought a decades-long Maoist insurgency and played roles in the mass pro-democracy protests of 1990 and the 2006 demonstrations that led to the abolition of the monarchy.

Analysts warn that the current crisis may be the army’s most significant political test since Nepal became a republic in 2008. “The army should not be involved in politics themselves but rather assist the president in getting the issues resolved with the protesting groups,” said Geja Sharma Wagle, a Kathmandu-based security and strategic affairs analyst. “Their role is to facilitate, support and assist wherever it needs to be. It is not suitable for the army to be involved in politics, which could draw them into much unwanted controversies.”

Some observers have noted parallels with neighboring Bangladesh, where a student-led movement helped oust a government and protest leaders later worked with the military to select an interim administration. In that case, Nobel laureate Muhammad Yunus led an interim government. Nepalese leaders and protesters have discussed naming an interim figure but have not agreed on a candidate, and there is no clear constitutional route for that arrangement in Nepal.

Security officials said the army’s swift deployment helped prevent wider destruction and further loss of life after police were overwhelmed. Still, the main challenges remain political: restoring civilian rule, filling the leadership vacuum and addressing the grievances that sparked protests. The army’s choice to step back from politics since 2008 complicates public expectations about its future role.

As Kathmandu begins the slow work of cleanup and recovery, many Nepalis expressed relief at the return of order but concern about the uncertain path ahead. The immediate task facing political leaders, the president and the military is to agree on a transitional arrangement that respects the constitution while preventing renewed violence.

Saaliq reported from New Delhi.