The Scottish Government's emergency Brexit legislation has been passed into law at Holyrood.
MSPs backed the UK Withdrawal from the European Union (Legal Continuity) (Scotland) Bill by 95 votes to 32.
Scotland's Brexit minister Michael Russell said the vote showed that Holyrood was "resolute in defending devolution".
It comes amid an ongoing row with Westminster over the return of devolved powers from Brussels once Britain leaves the EU.
The bill reached its third and final stage at the Scottish Parliament on Wednesday after being introduced last month.
Similar legislation was passed earlier in the day by the Welsh Assembly.
Both the Scottish and Welsh administrations have said they would not recommend granting legislative consent to the UK Government's EU Withdrawal Bill in its current form, branding it a "power grab".
They are angered by measures in the UK bill which would see some powers held by the EU not immediately passed to them.
SNP ministers say the Scottish Brexit bill is a necessary backstop to safeguard devolution and to ensure Scottish laws continue to function as normal after the UK leaves the EU.
The Scottish Government pushed through its bill despite Holyrood presiding officer Ken Macintosh's stated belief that the Scottish Parliament does not have the power to legislate on the matter, a situation that is unprecedented in the history of devolution.
However, the presiding officer's judgement is at odds with his counterpart in Cardiff, Elin Jones, who found its equivalent to fall within the Welsh Assembly's competence.
The Scottish Government's top legal officer, the Lord Advocate, has also advised that he believes the Scottish bill is within Holyrood's competence.
The country's three legal officers will now have 28 days to refer the legislation to the Supreme Court.
Russell insisted to MSPs that both he and First Minister Nicola Sturgeon still wanted to reach an agreement with the UK over changes to its Bill.
He said: "I remain hopeful an agreement can be reached. The First Minister, the Deputy First Minister and I have all made clear that is our first objective, and we will do our best to achieve it.
"But passing this Bill would be an important sign that the Parliament is resolute in defending devolution."
Russell described current UK legislation is an attempt to "turn the clock back to 1973 and allow the UK Government and it alone to redesign devolution, as if the UK had never been in the EU, Common Market or European Community.
"It was clear at the outset that this position was never going to get the agreement of any devolved administration worth its salt."
Scottish Conservative constitution spokesman Adam Tomkins said there were "grave doubts" about the legislation's competence.
The Tories were the only party in Holyrood to oppose the legislation - although Lib Dem Mike Rumbles MSP also voted against it - with Tomkins describing it as "bad law" which sought to "sow the seeds of division within the United Kingdom".
A UK Government spokeswoman said: "Our focus continues to be on finding an agreed way forward with the devolved administrations on the EU (Withdrawal) Bill. Everyone agrees this is the preferred option.
"As with all Scottish Parliament bills, the competence of the Continuity Bill will be considered by the law officers."