Scotland's Lord Advocate has defended the "continuity bill" brought forward by ministers as part of an ongoing row over post-Brexit powers.
Holyrood's presiding officer has said the bill falls outwith the Scottish Parliament's remit.
But top lawyer James Wolffe said the bill was "carefully framed" to be in line with UK and EU law.
The government intends to press ahead with the legislation even without the backing of the presiding officer.
MSPs will discuss proceeding with the UK Withdrawal from the European Union (Legal Continuity) (Scotland) Bill as an Emergency Bill on Thursday.
This is an unprecedented move - a government bill has never before gone forward without the support of the presiding officer, and a bill has never received Royal Assent under these circumstances.
The bill is the latest act in a long-running row between the Scottish and UK governments over how powers currently exercised from Brussels are distributed once the UK leaves the EU.
The Scottish and Welsh governments have both indicated that they will not put forward the EU Withdrawal Bill for devolved consent votes as things stand, and have now tabled their own legislation as a stop-gap solution.
Ministers have said their preference would still be to strike a deal over the Westminster legislation - but say drawing up their own is necessary as a contingency plan.
When the bill was published on Wednesday, Presiding Officer Ken Macintosh made clear that he did not believe the Scottish bill fell within Holyrood's legislative competence.
In a written statement on Tuesday, he raised concerns that the legislation might fall foul of EU law.
Mr Macintosh said the bill "anticipates the impact of the withdrawal of the United Kingdom from the European Union", and as such "assumes that the parliament can make provision now for the exercise of powers which it is possible the parliament will acquire in the future".
However, Mr Wolffe told MSPs that the bill had been "carefully framed" to ensure that "nothing will be done that is incompatible with EU law, before withdrawal from the EU".
He stressed to Mr Macintosh that "I would not wish it to be thought that I am expressing any criticism of you", but said "the government is and remains satisfied that this bill is within the legislative competence of the parliament".
The Lord Advocate, who can speak in the Holyrood chamber as a government minister, said the bill had been "carefully drafted so that it is not incompatible with EU law".
He said that given the UK is on track to leave the EU in March 2019, there was "an urgent practical necessity to make provision... to enable the law to operate effectively immediately upon and after the UK's withdrawal from the EU".
He said: "The bill does nothing which will alter European Union law, or which undermines the scheme of EU law, while the United Kingdom remains a member of the EU."
Mr Wolffe said this was the same principle that the EU Withdrawal Bill itself is based upon, saying: "If, contrary to the view of the Scottish government, this bill is incompatible with EU law, then the same reasoning would apply equally to the UK government's bill."
The fact Mr Macintosh has not backed the bill could potentially leave it open to legal challenge.
Mr Wolffe told MSPs that the matter "could, ultimately, if necessary, be tested in the courts", but said he was "not going to anticipate the hypothetical".
Pressed on what would happen if the court struck down the legislation, which could potentially leave a gap in Scottish law, the Lord Advocate replied: "I have spent a lot of time in my career avoiding hypothetical questions."