THERESA May is facing the threat of a fresh crisis after the top law officers in Northern Ireland and Wales backed the Scottish Government ahead of a courtroom showdown.

The Supreme Court in London will consider whether or not the EU Continuity Bill, passed in Holyrood amid an ongoing row with the UK Government of its Brexit legislation, breaches the powers of the Scottish Parliament.

READ MORE: Barnier dismisses May's Brexit demands, saying they are fraud risk

A two-day hearing will get underway on Tuesday, when the Advocate General for Scotland will argue the Bill should not be allowed to go ahead.

READ MORE: Queen's estates not exempt from Brexit risk assessments

But it has now emerged that both Wales and Northern Ireland’s top law officers will formally intervene in the case – and are backing the Scottish Government on some of its key arguments.

In a submission to the Supreme Court, Northern Ireland Attorney General John Larkin said: “It is submitted that the 2018 Bill and all of its provisions are within the legislative competence of the Scottish Parliament and this reference (by the UK Government) should be disposed of accordingly.”

A verdict is not expected to be given by the Court until October – the same month as the Prime Minister is scheduled to sign off her EU withdrawal deal.

If the Supreme Court does not back the UK Government’s view that the Scottish Government’s Bill is not within Holyrood’s legislative competence then it will present another major headache for May.

Earlier this month it emerged Tory ministers are reportedly plotting how they could undermine the authority of the UK’s highest court if its decides to back Scotland’s Brexit legislation.

The course of action – described as “the nuclear option” – is being drawn up ahead of the Supreme Court hearing.

The Scottish Government proposed its own Continuity Bill as it continued to reject May’s plans, saying the EU Withdrawal Bill amounts to a “power grab” because the views of Holyrood could be overruled when setting UK-wide frameworks in 24 areas, including GM crops, animal welfare, food labelling and food standards.

The Scottish Government’s Continuity Bill was fast-tracked through the Scottish Parliament last month. That happened despite Holyrood Presiding Officer Ken Macintosh ruling that it was not within Holyrood’s “legislative competence”.

He said the Continuity Bill “assumes that the parliament can make provision now for the exercise of powers which it is possible the parliament will acquire in the future”.

But Jeremy Miles, Counsel General for the Welsh Government, said in his submission to the Supreme Court that “there is nothing wrong in principle with legislation being lawful and competent by design, by reference to future contingency”.

Experts expect the court to rule that some aspects of the Scottish Government’s Bill is within the competence of the Scottish Parliament while others are not.

This would mean the Bill would have to go back to Holyrood to be amended before discussions between the two governments could take place.

A UK Government spokesman said: “We have referred the Scottish Parliament’s Continuity Bill to the Supreme Court to seek legal certainty as to its competence.”

A Scottish Government spokesman said: “The Lord Advocate has set out in his written case that it is within the powers of the Scottish Parliament to prepare for the consequences for devolved matters of UK withdrawal from the European Union.”

If the UK side win, the Holyrood bill will be struck down. But if the Scottish Government wins, the UK Government is said to be looking at ways to ensure the Westminster legislation could stand anyway.

“There are some in legal circles in the UK Government who said this wouldn’t work and that Westminster basically would have to flex it constitutional muscles and look to strike down the Holyrood legislation,” David Porter, the BBC’s Westminster correspondent told Good Morning Scotland at the time.