MSPs are set to ignite a constitutional crisis by backing legislation which could lead to an unprecedented legal battle between the Scottish and UK governments.

Amid continued stalemate between Edinburgh and London over the distribution of devolved powers after Brexit, Holyrood is due to pass its own alternative Brexit law today.

Introduced as a "fallback" option and regarded as a tactical device to wring concessions from London, the EU (legal continuity) Bill is now poised to become reality.

Only the Tories have so far opposed the legislation.

Both governments admitted an eleventh hour deal was unlikely, and they expected the Bill to proceed to its final Stage 3 vote.

The First Minister’s official spokesman said: "The expectation is it will go ahead as scheduled. There’s nothing to suggest otherwise.”

When the SNP Brexit minister Michael Russell tabled the emergency legislation three weeks ago, he said his preference would be to withdraw it following a cross-border deal.

However the UK and Scottish government remain divided over what happens to 24 key devolved powers, including food standards, farm payments and procurement, after Brexit.

The UK wants them to lie at Westminster after repatriation from Brussels pending the creation of UK-wide common frameworks to protect the UK internal market.

The Scottish Government says this “power grab” would undermine the devolution settlement, and at the very least Holyrood’s consent should be required to create frameworks, something Westminster regards as a veto power.

The Continuity Bill is intended to transfer devolved EU law into Scots law at Brexit if the two sides cannot reach agreement on how to amend the EU Withdrawal Bill in the Lords.

If the Continuity Bill passes, the dispute is likely to move swiftly to the UK Supreme Court.

UK law officers would have four weeks to refer the Bill and ask for it to be struck down.

Holyrood presiding officer Ken Macintosh has already said the Continuity Bill is invalid on the basis it exceeds the parliament’s powers by venturing into EU law, but the Scottish Government, supported by the Lord Advocate, insist it is legislatively competent.

Asked about a potential Supreme Court showdown, the First Minister’s spokesman said: "That remains to be seen. It’s possible that it will, but I would not assume that it’s a given that it will end up there. I wouldn’t assume so, but it’s possible.”

MSPs are expected to sit into the evening to consider more than 60 amendments to the third and final stage of the Bill.

If passed, the Continuity Bill can still be scrapped if the UK and Scottish governments reach a deal and amend the Withdrawal Bill in the Lords in late April or early May.

The Labour-run Welsh government has tabled a parallel Continuity Bill for Wales.

A UK Government spokesperson said: “The EU (Withdrawal) Bill is essential legislation in the national interest that ensures the whole of the UK will have a functioning statute book on exit day. We are still hopeful that we can reach agreement with the devolved administrations on the Bill.

“The proposals being put forward by the Scottish and Welsh governments are unnecessary, and it would be more helpful to concentrate on reaching an agreement.

“The UK Government has put a considerable offer on the table and we would like the devolved administrations to engage constructively on the EU (Withdrawal) Bill.”