Pakistan's Supreme Court has ordered the restoration of the country's National Assembly, again plunging Prime Minister Imran Khan into political peril.
Five judges unanimously ruled that a decision to cast out a vote of no confidence in Mr Khan and dissolve parliament should be reversed.
The verdict, which follows four days of tense constitutional deadlock, is a serious legal blow to the prime minister.
The judges, led by Pakistan's chief justice, said the deputy speaker's April 3 shock decision to cast out the no-confidence vote was unconstitutional.
Mr Khan's dissolution of parliament was set aside by the judges, who also ordered the National Assembly to meet again on Saturday morning to proceed with the vote.
Pakistan's opposition, which had accused Mr Khan of staging a coup and had appealed against the decision, immediately welcomed the ruling.
"Democracy is the best revenge", said Bilawal Bhutto-Zardari, chairman of the Pakistan People's Party.
Shehbaz Sharif, Leader of the Opposition in the National Assembly, said the court had "definitely fulfilled the people's expectations".
Mr Khan had been widely expected to lose the no-confidence vote after a string of defections hit both his own party and the coalition he had formed to maintain a slim majority.
However, the deputy speaker, a close ally of Mr Khan, wrong-footed the opposition by kicking out the motion, suggesting it had been brought in collusion with foreign powers. Mr Khan immediately dissolved parliament and said he wanted new elections within 90 days.
The Supreme Court said this action was "declared to be contrary to the constitution and of no legal effect, and is set aside".
Thursday's ruling means Mr Khan must again run the gauntlet of a no-confidence vote in which the opposition is convinced it has numbers to push it through.
That would give opposition parties the chance to choose a new leader with Mr Sharif of the Pakistan Muslim League (Nawaz) most likely to be picked.
Mr Khan's grip on power has been weakened by public anger at double-digit inflation and worsening economic problems that have caused financial pain to many of his supporters and business backers. The rupee fell to its lowest ever level against the dollar on Thursday.
The former cricketer's relations with the military, which wields formidable political clout, have also worsened.
Mr Khan, who was elected in July 2018, made no immediate comment after the ruling.