THE UK’s highest court has broadly upheld the Holyrood Brexit Bill designed to ward off a Westminster ‘power grab’, but said key parts of it are now incompetent.

The Supreme Court said the Continuity Bill passed by MSPs in March was within the powers of the Scottish Parliament at the time.

However it also said much of it is no longer viable because of the subsequent passage of the EU Withdrawal Act at Westminster, which effectively gutted the Scottish legislation.

READ MORE: UK Supreme Court to rule on Holyrood Brexit bill 

The parts now deemed outside Holyrood’s “legislative competence” include the core aim of the Bill  - the transfer of EU law into Scots law on Brexit day, and the empowering of Scottish ministers to amend devolved EU law.

Lady Hale, the president of the Supreme Court, said the judgment was the unanimous view of the seven justices who considered the case.

The Scottish Government said the UK Government’s use of delaying tactics over the Holyrood Bill amounted to an “act of constitutional vandalism”.

On Twitter, Aileen McHarg, Professor of Public Law at Strathclyde University, said the judgment was “complex” and its consequences would need longer consideration.

She said the EU Withdrawal Act meant “quite a lot” of the Holyrood Bill had now fallen by the wayside, adding: “Will need to see how much this leaves (not a great deal, I think)”.

Tory MSP Adam Tomkins tweeted: “Supreme Court eviscerates the SNP’s Continuity Bill, striking down several of its key provisions. Judgment leaves the SNP’s legislation in tatters.

“The SNP were warned they were acting illegally. But they ploughed on regardless. Embarrassing day for Nationalist ministers. Again.”

The judgment, which followed a legal challenge by the UK government, is a Pyrrhic victory for the Scottish Government and its law officer, the Lord Advocate James Wolffe QC.

Holyrood presiding officer Ken Macintosh had warned the Continuity Bill was beyond the parliament’s powers, because it strayed into EU law.

However the Lord Advocate disagreed, and a majority of MSPs ignored the Presiding Officer’s advice, and passed the legislation 92-32 regardless, a first for devolution.

READ MORE: European Court of Justice ruling: Brexit legal bid explained 

Formally titled the “UK Withdrawal from the European Union (Legal Continuity) (Scotland) Bill”, the Holyrood legislation was designed to  block a perceived ‘power grab’ on devolved powers in the main Brexit law then going through Westminster.

The UK Government and Scottish Government were divided on how powers in devolved areas should be distributed once repatriated from Brussels after Brexit.

SNP ministers wanted all of the 100-plus devolved competencies to lie at Holyrood.

But the UK government wanted 24 to stay for several years at Westminster, including some covering agriculture, fishing and procurement to protect the UK single market.

The Continuity Bill was intended as a backstop, to be used if the two sides failed to agree the distribution of powers, which would transfer devolved EU law into Scots law at Brexit.

After Holyrood passed the Continuity Bill, the UK Government swiftly announced it would challenge it at the UK Supreme Court and attempt to have parts of it struck down.

The delay prevented the Holyrood Bill receiving Royal Assent and becoming law, a tactical as well as a legislative move which ultimately paid off the UK Government.

The two governments argued their positions at the Court over two days in late July, with Mr Wolffe pitted against the Advocate General for Scotland, Lord Keen.

In its judgment, the Supreme Court ruled that the Holyrood Bill as a whole was not contrary to the devolution settlement, nor the Scotland Act, nor to the rule of law.

This was a pointed rejection of the UK law officers' arguments.

Instead, it said only one section, Section 17,  was outside of Holyrood’s powers at the time because it would give effectively Scottish ministers a say over the powers of UK ministers.

However, the Court said it was not just a question of whether the Bill was competent when it was passed, but whether it would be competent if it received royal assent today,

And since the Bill was passed, the EU Withdrawal Act had been passed at Westminster, and that had changed the legislative landscape, Lady Hale said.

That meant numerous sections of the Scottish Bill were now outside Holyrood’s powers, as they would amend the Withdrawal Act, which is protected against modification by Holyrood.

Scottish Secretary David Mundell said: “The Supreme Court has provided much-needed legal clarity that the Continuity Bill goes beyond the powers of the Scottish Parliament.

“This demonstrates clearly that it was the right thing for the UK Government to refer the Bill to the Court. It is now for the Scottish Government to consider how to proceed, and we hope Holyrood will take a pragmatic approach and work constructively with us as we leave the EU.”

SNP Constitutional Relations Secretary Michael Russell said: “The Scottish Government's position has been vindicated by the Supreme Court judgment, which confirms that the Scottish Parliament had the competence to prepare its own laws for Brexit when the Continuity Bill was passed.

"Worryingly, parts of the Bill have been thwarted as a result of steps taken by the UK Government. For the first time ever, UK Law Officers delayed an act of the Scottish Parliament from becoming law by referring it to the Supreme Court.

"Then the UK Government, for the first time ever, invited the UK Parliament to pass a Bill which they knew would cut the powers of the Scottish Parliament without its consent. The UK Government changed the rules of the game midway through the match.

"This is an act of constitutional vandalism but that does not take away from the fact this judgment makes clear MSPs were perfectly entitled to prepare Scotland's laws for Brexit at the time this Bill was passed.

“The UK Government's arguments have been clearly rejected.

"We will now reflect on this judgment and discuss with other parties before coming back to Parliament to set out the best way forward."

Andrew Henderson, director of public policy at law firm Pinsent Masons, said: “Today’s ruling will see both sides claim victory.

"The Court has found that the Scottish Parliament did act outside of its legislative competence on one count – pursuing measures which might result in modification of the Scotland Act, a power the devolved institutions of Scotland do not enjoy. The UK Government and opponents of the SNP will trumpet this aspect of the ruling.

“However, other elements of the UK Government’s case have been thrown out by the Supreme Court.

"We can expect the Scottish Government and its supporters to celebrate the ruling that the remainder of the legislation was within the competence of the devolved institutions.”