SNP ministers have threatened to rush emergency legislation through the Scottish Parliament if the UK government fails to overhaul its main Brexit Bill.

Brexit minister Michael Russell and parliamentary business minister Joe FitzPatrick warned Holyrood’s Presiding Officer of their intent after MSPs criticised the EU (Withdrawal) Bill.

The move, which could end up in a UK Supreme Court battle, is intended to put pressure on the UK government to amend the Bill to the SNP’s satisfaction in the coming weeks.

Holyrood’s cross-party finance and constitution this week said the Bill was “incompatible with the devolution settlement” in its current form and should be denied legislative consent.

In a letter to Holyrood PO Ken Macintosh, the ministers said they wanted to work with the UK government to amend the Bill successfully, but also had to prepare for failure and Holyrood withholding its consent, something that would trigger a constitutional crisis.

“To that end our officials are developing a Continuity Bill for Scotland,” they wrote.

Its purpose would be to “ensure that Scotland’s laws can be prepared for the effects of EU withdrawal even if it does not prove possible to rely on the UK Bill”.

They said they would seek an “expedited timetable” to pass the legislation “quickly”, with pre-introduction scrutiny later this month and formal introduction of the Bill in February.

The ministers stressed they had not “definitely resolved” to reject the EU (Withdrawal) Bill, now going through the Lords, but needed to have a contingency plan.

In theory, a Continuity Bill would freeze EU law in devolved areas on the date of Brexit and ensure laws in Scotland remained operable thereafter.

Such a Bill would be highly contentious legally, but could be useful as political leverage, pushing the UK government into overhauling the EU (Withdrawal) Bill to the SNP’s liking.

A recent comment piece from the Institute of Government said a Continuity Bill would face a number of hurdles, including prior passage of the EU (Withdrawal) Bill making it redundant.

If Holyrood passed the Bill, it could also be ignored by the UK Government or challenged at the UK Supreme Court - although both these options could rebound on the Tories politically.

The 1998 Scotland Act makes it clear that unless powers are specifically reserved to Westminster, they should be exercised at Holyrood by default.

However the EU (Withdrawal) Bill would see all powers repatriated from the EU at Brexit going to Westminster, at least initially, even those in devolved areas.

The Scottish and Welsh governments say this is a “naked power grab”.

Green MSP Ross Greer said: “That the Scottish Government has to prepare a Continuity Bill is yet another example of the absolute shambles the UK government has made of this process. This was entirely avoidable, but the Tories voted down amendments, drafted by the Scottish and Welsh governments, which would have resolved these issues.

“Brexit is not a mess of Holyrood’s making, yet it seems our parliament is more adequately prepared for leaving the EU than Westminster.”

A UK Government spokesperson said: "We want the whole of the UK to come together in support of this legislation [the EU (Withdrawal) Bill], which is crucial to delivering the outcome of the referendum. Every part of the United Kingdom needs a functioning statute book, and that applies as much to Scotland as elsewhere."