Boris Johnson's prorogation of Parliament was "unlawful", the highest civil court in Scotland has ruled.
A legal bid to challenge the suspension of Parliament by a cross-party group of 70 parliamentarians was initially rejected at the Court of Session, but the appeal was successful.
The UK government now plans to appeal against the latest ruling to the Supreme Court.
The ruling comes a day after the prorogation took place in the early hours of Tuesday, with Parliament now suspended for five weeks.
At the appeal hearing on Friday Aidan O'Neill QC, representing the parliamentarians, claimed prorogation was unlawful in his closing arguments.
He said: "A decision to prorogue shuts down Parliament. It is in those circumstances an attack on democracy.
"It is an attack on the balance of the constitution and therefore is is unlawful."
David Johnston QC, representing the UK Government, had argued it was not for the courts to get involved in what was a political decision.
Shadow Brexit secretary Keir Starmer said the court ruling was "huge", and vindicated Labour's efforts to stop Parliament being shut down.
Speaking at the TUC Congress in Brighton, he said: "I need to get back to Parliament, to see if we can reopen the doors and hold Johnson to account.
Meanwhile, one of the petitioning barristers on the case, Jolyon Maugham QC, claimed "the effect of the decision is that Parliament is no longer prorogued".
SNP MP Joanna Cherry QC, who was among the cross-party group of politicians that brought the action, tweeted:
Judge Lord Doherty originally dismissed a challenge against the suspension - which went ahead in the early hours of Tuesday - at the Court of Session last Wednesday, saying it is for politicians and not the courts to decide.
But three judges of the Inner House, the supreme civil court in Scotland, disagreed with Lord Doherty's ruling.
SNP Westminiter leader Ian Blackford tweeted:
"You have acted in an anti democratic manner and need to respond by recalling Parliament."
"We believe that the effect of the decision is that Parliament is no longer prorogued.
"I have never been able to contemplate the possibility that the law could be that our sovereign Parliament might be treated as an inconvenience by the Prime Minister."