CNN  — 

The UK government’s decision to shut down Parliament in the run-up to Brexit was illegal, Scotland’s highest civil court has ruled, in a serious blow to embattled Prime Minister Boris Johnson.

In a devastating ruling, a panel of three senior judges unanimously declared that Johnson’s advice to the Queen to suspend Parliament for five weeks was “unlawful.”

Johnson has always insisted that his decision was a routine device that allowed the government to start a new parliamentary session with a fresh legislative agenda. But the Scottish judges disagreed, saying it was motivated by the “improper purpose of stymying Parliament.”

“This was an egregious case of a clear failure to comply with generally accepted standards of behaviour of public authorities,” ruled one of the judges, Lord Brodie, according to a summary of the decision posted online.

The court did not immediately issue an order to lift the suspension – also known as prorogation – noting that the High Court in London had come to a different conclusion and that the UK Supreme Court would need to resolve the issue. The government confirmed that it would appeal the Scottish court’s decision to the Supreme Court.

A protester holds a placard at the gates of Downing Street during a demonstration against the UK Government's decision to  prorogue parliament.

Joanna Cherry, a member of Parliament for the Scottish National Party, who was the lead petitioner in the cross-party group of politicians which brought the action, said the decision was a “historic ruling.”

Dominic Grieve, who was attorney general in the government of former Prime Minister Theresa May, said if it was established that Johnson had misled the Queen, he would have to resign.”If that were to to be the case that this had happened, Boris Johnson would find himself in an untenable position in Parliament,” he told the BBC.