Sri Lanka's top court has ruled that the president's dissolution of parliament last month was unconstitutional, as a political crisis continues to grip the nation.
President Maithripala Sirisena dismissed his prime minister and replaced him with former leader Mahinda Rajapaksa in late October.
When that decision was contested, he dissolved parliament.
The ruling could see sacked PM Ranil Wickremesinghe return to office.
The legislature, which has been sitting after a temporary ruling from the Supreme Court - has already passed two no-confidence motions against Rajapaksa.
The controversial but popular leader was president at the end of Sri Lanka's nearly three decade-old civil war in 2009 and is accused of presiding over vast human rights abuses, which he denies.
On Wednesday, the parliament passed a vote of confidence in Ranil Wickremesinghe as prime minister.
His party and its allies have a simple majority in parliament - and have argued from the beginning that President Sirisena's actions, including calling a snap election nearly two years ahead of schedule, were unconstitutional.
The Supreme Court on Thursday said the president could not dissolve parliament until it was four-and-a-half years through its five-year term.
Correspondents say that if the president does not accept the top court's decision, it could lead to impeachment proceedings. However this would require the support of a two-thirds majority in parliament and a special inquiry by the Supreme Court.
In a tweet, Mr Wickremesinghe called on President Sirisena to "promptly respect the judgment of the courts".
He is yet to comment. Namal Rajapaksa, an MP and son of Mahinda Rajapaksa, tweeted: "We respect the decision of [Sri Lanka's] Supreme Court, despite the fact that we have reservations regarding its interpretation."
The political crisis, which began on 26 October when President Sirisena shocked the nation by suddenly sacking his PM, is being closely watched by the US, India, China and the European Union.
The government has been in paralysis since an appeals court ruling last week that restrained Mr Rajapaksa from acting as prime minister, in a separate case brought by 122 MPs.
The crisis - which has provoked brawls in parliament and sparked large protests - has hurt tourism, which makes up about 5% of the country's economy.