The Supreme Court in Kathmandu, Nepal, on May 24, as parliamentarians filed a writ petition against the decision to dissolve parliament.

Nepal’s Supreme Court on Monday reinstated its parliament, which was dissolved by caretaker Prime Minister K.P. Sharma Oli in May, and ordered that his rival Sher Bahadur Deuba be appointed as prime minister.

The move deals a major blow to Oli, who was unable to muster a majority in the House of Representatives and had sought to force a fresh election by dissolving parliament on May 22.

Oli’s move had sparked a fresh constitutional crisis in the Himalayan nation, as it struggled to contain an outbreak of coronavirus that saw hospitals overwhelmed and medical oxygen run out. It also marked his second attempt to dissolve parliament in recent months after an initial attempt in December 2020, following a split in his party, was reversed by the Supreme Court in February.

After Nepal’s parliament had been reconstituted, Oli lost a confidence vote on May 10 and was removed from his position.

Before his rivals could stake a claim however, he advised Nepal’s President Bidya Devi Bhandari to dissolve parliament, saying neither he nor opposition leader Deuba were able to muster a majority and form a new government.

The opposition decried the move and vowed to challenge it.

On Monday, Supreme Court official Debendra Dhakal said the court had ordered parliament be reconvened within seven days.

It also ordered that Sher Bahadur Deuba, who has previously served four terms as prime minister, be re-appointed as prime minister by 5 p.m. local time on Tuesday.

“The court has not left any room for political maneuvering by the outgoing prime minister,” said Bipin Adhikari, a constitutional expert and analyst.

Deuba, 75, heads the centrist Nepali Congress party. He had attempted to form a new government after Oli failed to garner a majority among lawmakers.

Nearly two dozen rebels from Oli’s Communist Unified Marxist Leninist (UML) party were expected to support Deuba at the time.

“The court has saved democracy. Now five political parties will form a coalition government,” Deuba said.

Oli was not immediately available for comment. His aide, Rajan Bhattarai, said the court’s decision would be respected – but called it “a wrong political decision, which will have long-term implications on the parliamentary democracy in our country.”

Dozens of Oli’s supporters protested near the parliament building against the decision.

Oli was elected in early 2018 as head of an alliance with the Maoist Centre, a group of former Maoist rebels, promising to end corruption and bring economic development to one of the world’s poorest countries.

But some allies accused him of undermining colleagues and ignoring party decisions in making policies and key government appointments.