Prime Minister Boris Johnson says the UK's destiny "now resides firmly in our hands" as his European Union trade deal cleared British parliament and entered into law.
The EU (Future Relationship) Act received the backing of the Commons and Lords as the government rushed approval through both houses in a single day.
It was announced that the legislation had been granted royal assent at 12.25am on Thursday morning, signing the agreement finally reached between the UK and EU on Christmas Eve into law.
The Act paves the way for the deal to take effect at 11pm on Thursday when the current Brexit transition period - during which the UK has continued to follow EU rules - ends.
In a statement after the deal cleared parliament, Johnson said: "I want to thank my fellow MPs and peers for passing this historic Bill and would like to express my gratitude to all of the staff here in Parliament and across Government who have made today possible.
"The destiny of this great country now resides firmly in our hands. We take on this duty with a sense of purpose and with the interests of the British public at the heart of everything we do.
"11pm on the 31st December marks a new beginning in our country's history and a new relationship with the EU as their biggest ally. This moment is finally upon us and now is the time to seize it."
MPs backed the Bill by 521 to 73 at third reading, while peers gave it an unopposed third reading late on Wednesday night.
Labour supported the deal, despite misgivings from some pro-European MPs who said they would be abstaining or voting against.
Party leader Sir Keir Starmer said that, while the agreement is "thin" with "many flaws", the alternative is to leave the EU single market and customs union with no agreement, pushing up prices and driving businesses to the wall.
But he suffered a rebellion which prompted two junior shadow ministers, Helen Hayes and Tonia Antoniazzi, to announce they were resigning their posts on the Labour front bench as they could not support the agreement.
One Labour MP, Bell Ribeiro-Addy, defied the whips to vote against the agreement while another 36 abstained.
All the other opposition parties opposed the agreement, including the DUP, which backed Brexit but objects to provisions which mean Northern Ireland will still be subject to some EU rules.
Tory Eurosceptics were jubilant, declaring that the "battle for Brexit" had finally been won.
Veteran Sir Bill Cash said: "Like Alexander the Great, Boris has cut the Gordian Knot."
Mark Francois, one of the self-styled Spartans who held out against Theresa May's Brexit withdrawal agreement, said they could now "lower our spears".
Earlier in the day, European Commission president Ursula von der Leyen and European Council president Charles Michel formally signed the agreement.
Following the brief ceremony in Brussels, the documents were flown to London by the RAF where Johnson put his name to it.
Michel said: "It is a fair and balanced agreement that fully protects the fundamental interests of the European Union and creates stability and predictability for citizens and companies."
At Holyrood, the Scottish Parliament voted by 92 to 30 to deny the deal legislative consent, although First Minister Nicola Sturgeon acknowledged it would not affect the passage of the Bill at Westminster.
"The fact is, Scotland's voice has been ignored on Brexit all along, every single step of the way," she said.
"It is only through independence that we will ever get to choose the future we want."