Nepal's top court ousted the sitting prime minister and reinstated the dissolved parliament Monday, plunging the Himalayan nation into further political uncertainty.
The country has been in a political crisis for months amid infighting between Prime Minister K.P. Sharma Oli and senior leaders of his party.
"The dissolved parliament will be reinstated," the court wrote in its judgement.
Oli first moved to dismiss parliament in December, but it was reinstated by the Supreme Court, which called his move unconstitutional.
The 69-year-old then lost a vote of confidence in the lower house of parliament.
But he was reinstated as PM after the main opposition parties were unable to obtain a majority of support in the bicameral parliament.
Oli tried again to dissolve parliament in May, but his decision was challenged by lawmakers and political activists in the top court.
The court said in its judgement that the main opposition leader Sher Bahadur Deuba should replace Oli by late Tuesday, as he had presented "a claim (of majority)... as the prime minister".
Deuba has to win a vote of confidence in the lower house within a month to retain the prime ministership.
Deuba, the head of the Nepali Congress, earlier claimed to have the support of 149 members of the 275-seat lower house.
Political analyst Lok Raj Baral told AFP the court had stopped Oli from "doing as he pleases".
"Political stability ahead depends on an alliance among sharply divided political parties and their factions," he added.
The Oli government came to power in 2018 with a two-thirds majority.
There was optimism that his strong mandate at the polls would end years of instability and short-lived governments exacerbated by a devastating earthquake in 2015.
Deuba was elected as Nepal's prime minister four times between 1995 and 2018, including during the brutal, decade-long Maoist insurgency.