SNP ministers have lost a pair of related cases about the extent of Holyrood’s powers at the UK Supreme Court, with potential implications for a second independence referendum.

Five justices, including the court’s Scottish president Lord Reed, said two Bills passed by MSPs in March were incompatible with the 1998 Scotland Act that underpins devolution.

They said four provisions of a Bill about children's rights and two provisions of a Bill about local government were outside the parliament's legislative competence. 

They also criticised the way the children's rights Bill would rely on the courts to clarify its extent through litigation, instead of being clear about its extent upfront.

That approach would force courts to take on functions well beyond interpeting the law as currently understood,  circumvent established pre-legislative checks, and make it harder to rely on what Holyrood Bills said in future.

The Court's decision was unanimous.

It means the legislation will now be referred back to Holyrood for ‘reconsideration’.

If MSPs decide to modify the Bills in line with the ruling, they should receive royal assent and become law.

Deputy First Minister John Swinney, who had had rejected warnings about the Bills' competence, said it laid bare the weakness of the devolution settlement.

The ruling followed a challenge by the UK Government, which warned SNP ministers before the laws were passed that they strayed outside the Scottish Parliament’s remit.

The Court’s decision is a blow to Nicola Sturgeon, who argued during the Holyrood election that the UK challenge was a sign of Westminster’s overreach and insensitivity. 

SNP Westminster Ian Blackford also told Boris Johnson at PMQs that the challenge was “shameful”, given one of the Bill’s concerned children’s rights.

However the Court agreed with the UK Government that parts of the Bills were fundamentallly at odds with the Scotland Act as they purported to impinge on Westminster’s sovereignty and its ability to make laws for Scotland in all areas, including devolved areas.

This was incompatible with Section 28(7) of the Scotland Act, they said.

The Court’s interpretation of the Scotland Act and the limit of Holyrood’s powers could potetntially have a bearing on the independence debate.

Ms Sturgeon has said that if the Prime Minister continues to block a second referendum, Holyrood will pass a Referendum Bill without Westminster consent.

Because the 1998 Scotland Act says the Union is an issue reserved to Westminster, such a Bill would almost certainly be challenged by the UK Government at the Supreme Court.

The ruling today suggests the Court is unlikely to take the kind of flexible approach that the Scottish Government would need to defeat such a challenge, although every case is of course decided on its merits.

Glasgow University law professor Adam Tomkins, a former Tory MSP, told the Herald: "Holyrood has never been able, as a matter of law, to legislate to limit Westminster’s ongoing ability to make law for Scotland.

"This is the second Supreme Court judgment (following on from the Continuity Bill Reference in 2018) in which the Justices have given that rule an expansive reading.

"Any provision of an Act of the Scottish Parliament, which directly or indirectly, actually or potentially modifies Westminster’s ability to make law for Scotland is now liable to be struck down by the courts.

"If that doesn’t hole below the waterline any plans the Scottish Government may have for seeking to legislate for a repeat referendum on independence without Westminster’s consent, I don’t know what will.”

Today’s ruling concerns two Bills passed unanimously by MSPs in March.

The United Nations Convention on the Rights of the Child (Incorporation) (Scotland) Bill is intended to incorporate a UN treaty into Scottish law, which would require public authorities to respect children and young people’s rights.

It also would let children, young people and their representatives go to the courts to enforce their rights, and allow courts to strike down legislation that is incompatible with the UNCRC.

The other Bill is meant to incorporate an EU Charter on local Government into Scots law.

Before the Bills were passed, Scottish Secretary Alister Jack flagged concerns that the legislation could stray beyond Holyrood’s existing powers.

However Mr Swinney dismissed his intervention as “menacing” and a “power grab”, and the legislation was passed regardless.

The UK law officers, The Attorney General and Advocate General for Scotland, then referred both Bills to the Supreme Court for a definitive ruling on competence.

They argued “both Bills would bestow upon the Scottish courts extensive powers to interpret and scrutinise primary legislation passed by the sovereign UK Parliament”.

As that would modify Section 28(7) of the Scotland Act 1998, which states Holyrood’s power to make laws, “does not affect the power of the Parliament of the United Kingdom to make laws for Scotland”, the UK law officers argued parts of the Bills were therefore “outside the legislative competence of the Scottish Parliament”.

The UK law officers also sought the court’s guidance on the correct reading of the Bills to ensure they are within Holyrood’s legislative competence, “if such a reading is possible”.

The Court heard submissions from both the UK and Scottish governments over two days in June.

Sir James Eadie QC, for the UK law officers, told the court there were “manifold and obvious competence problems” with the Bills. 

READ MORE: SNP accused of 'playing games with children's rights' after court defeat

In particular that they “purport to bestow upon the Scottish courts extensive and, in part, unparalleled powers to interpret and to scrutinise the legality of primary legislation passed by the sovereign UK Parliament at Westminster.”

He said: “The Scottish Parliament is purporting to require Acts of the sovereign Parliament to meet a test to which Parliament has not assented and which may indeed conflict with a purpose Parliament is seeking to achieve.

“The relevant Bills subject Acts of the UK Parliament, both past and future, to what is in effect characterised as a superior body of law, the UNCRC and the European Charter.

“It does so in circumstances in which those UK parliamentary Acts are not so subject to the authority of the sovereign parliament. The Bills do not restrict the introduction of the UNCRC in that way to legislation of the Scottish Parliament only.”

James Mure QC, for Scotland’s top law officers, the Lord Advocate, said none of the provisions in the Bills modified the law on the relationship between the powers of Westminster and Holyrood “on a proper reading”.

He argued that if the application of part of one of the Bills was beyond the scope of the Scottish Parliament, it would be read narrowly to keep it within its legislative powers.

“Within legislative competence at least, Acts of the Scottish Parliament cannot be regarded as hierarchically inferior to Acts of the Westminster parliament, because within legislative competence both effectively have supremacy in the legal system in Scotland.”

He added that for Holyrood to legislate “consistently” across the Scottish statute book, it should be able to “condition the continuing legal force and effect” of Westminster Acts of Parliament so “they fit with the policy decided by the Scottish Parliament”. 

However many of the justices complained the Bills were confusing and badly drafted.

Lord Reed accused Mr Mure of advancing a “completely meaningless” argument, when he suggested the Bills were automatically competent because MSPs had passed them knowing the extent of Holyrood’s powers.

Lord Reed also said the drafting would “guarantee” legal uncertainty, as it effectively left it to the courts “to sort out the problems on a case-by-case basis”, instead of the legislation being clear on its face about its limits.

He said at the time: “In most liberal democracies one expects the law of the land to be publicly available and accessible. Whereas this technique of drafting guarantees that the one thing you can be sure of is that the terms of the statute do not represent the law.

“You draft the legislation as if the constraints in the Scotland Act didn’t exist, and then you leave it to the courts to sort out the problems on a case-by-case basis.”

Mr Mure admitted it would require litigation in the courts, after the Bills became law, to determine their precise legislative extent, perhaps “a whole series of cases”.

He accepted legal certainty would only “become clearer over time", adding: "But it’s not irredeemably unclear for the purpose of an Act of the Scottish Parliament in my submission.”

Justices also noted parts of the UNCRC Bill were “inconsistent”, saying both that a court could declare legislation UNCRC incompatible in a “non binding” way, yet such legislation would also be “unlawful”, allowing public bodies to be sued if they enforced it.

Delivering today's ruling, Lord Reed said there was no dispute about Holyrood’s ability to incorporate the charters into Scots law - the issue was the manner in which they sought to do it.

He said Court had unanimously decided that sections 6, 19(2)(a)(ii), 20(10)(a)(ii) and 21(5)(b)(ii) of the UNCRC Bill and sections 4(1A) and 5(1) of the European Charter Bill would be outside the legislative competence of the Scottish Parliament.

The Court decided that the latter three provisions of the UNCRC Bill would modify section 28(7) of the Scotland Act and, for that reason, fall outside Holyrood’s legislative competence.

Section 6 of the UNCRC Bill also left it to the courts to decide how the Bill should operate in practice, forcing them to "assume a function which goes beyond interpretation as ordinarily understood".

This would also circumvent the system of pre-enactment scrutiny established by Sections 31-33 of the Scotland Act

"As it cannot properly be left to the courts to impose the necessary qualifications, section 6 of the UNCRC Bill would be outside the legislative competence of the Scottish Parliament."

The Court also ruled Sections 29(2)(a)(ii) and 21(5)(b)(ii) of the European Charter of Local Self-Government (Incorporation) (Scotland) Bill were outside Holyrood's competence as they purported to modify Section 28(7) of the Scotland Act by giving courts the power to declare UK Acts of Parliament incompatible, and so affecting Westminster's sovereign right to legislate for Scotland.

Responding to the ruling, Mr Swinney said: "While we fully respect the court’s judgment, it lays bare the weakness of, and the limits in, the devolution settlement.

"The ruling means it is outwith the power of the Scottish Parliament to pass legislation it considers necessary to fully ensure the rights of Scotland’s children are protected.

“The UNCRC Bill was created to deliver a revolution in children’s rights, making sure children and young people are involved in decisions that affect their lives.

"The Bill was backed unanimously by the Scottish Parliament and celebrated as a landmark by campaigners across the country.

“The European Charter of Local Self-Government Bill strengthens local government by incorporating the Charter into Scots law.

"Starting as a Member’s Bill, it, too, was passed unanimously by the Scottish Parliament and it was supported by local government and COSLA.    

“Today’s judgment will require careful consideration. I will update Parliament further later today, but one thing is already crystal clear: the devolution settlement does not give Scotland the powers it needs.”

Scottish Secretary Alister Jack said: “I welcome the UK Supreme Court’s decision, which provides vital legal clarity on these two bills.

"As set out in the Scotland Act 1998, the Scottish Parliament cannot legislate outwith its areas of competence.

"As we have been clear, our concerns were never to do with the policy of the Bills, but about whether they are within the legislative competence of the Scottish Parliament.

"We will continue to work collaboratively with the Scottish Government to address any competence concerns with future Scottish Parliament legislation.”