The European Court of Justice has ruled the UK can cancel Brexit without the permission of the other 27 EU members.
The ECJ judges ruled this could be done without altering the terms of Britain's membership.
A group of anti-Brexit politicians argued the UK should be able to unilaterally halt Brexit, but they were opposed by the government and EU.
The decision came as Theresa May announced a Commons vote on whether to approve her deal would be postponed.
MPs had been widely expected on Tuesday to reject the EU withdrawal agreement negotiated by Mrs May.
But she pre-empted their decision, saying the vote would be deferred to a later date so she could seek "further assurances" from EU leaders about the application of the Irish border backstop.
In a subsequent statement to MPs, Brexit Secretary Steve Barclay said the government noted the ECJ ruling but insisted "our policy has not changed".
He said the UK would be leaving the EU on 29 March 2019, under the terms of the EU's Article 50 process, and had "absolutely no intention" of overturning the 2016 Brexit vote.
"The government's firm and long held policy is that we will not revoke the Article 50 notice," he said.
What was the court case about?
The case was brought by a cross-party group of Scottish politicians and the Good Law Project who wanted to know whether the UK could revoke the decision to leave the EU without getting approval from the other member states.
They believed that if the ruling went in their favour, it could pave the way for an alternative option to Brexit, such as another referendum.
Both the UK government and the EU had been against it going to the ECJ.
The EU warned that it would set a dangerous precedent by encouraging other countries to announce they were leaving in an attempt to secure better membership terms, before cancelling their withdrawal.
The UK government's lawyers also argued that the case was purely hypothetical as "the UK does not intend to revoke its notification" and those politicians behind it wanted to use the case as "political ammunition to be used in, and to pressure, the UK Parliament".
What does the ruling say?
The ECJ ruled that the UK can unilaterally revoke its withdrawal from the EU, broadly following the non-binding opinion given last week by a senior ECJ official - the advocate general.
The statement from the court said the ability for a member state to change its mind after telling the EU it wanted to leave would last as long as a withdrawal agreement had not been entered into, or for the two-year period after it had notified the bloc it was leaving.
If that two-year period gets extended, then a member state could change its mind during that extra time too.
The court said the UK would be able to stay on the same terms it has now, so it would not be forced to join the euro or the Schengen area - where there are no passport controls between countries.
But the decision to stay must "follow a democratic process".
The member state would then have to write to the EU to notify them of the "unequivocal and unconditional" decision.
The ECJ said it made the ruling to "clarify the options open to MPs" ahead of voting on Mrs May's deal.
How have campaigners reacted?
The politicians involved hope the victory will increase the chances of Brexit being called off completely, potentially through another referendum.
Scottish Green MSP Ross Greer - one of the politicians who launched the case - said: "This is a massive moment at the start of a vital week, pointing to a clear way out of the Brexit mess."
And the SNP's Alyn Smith, who was also involved in the case, said: "A bright light has switched on above an exit sign."
This is the 1st win for #Scotland in the #Brexit process. It won’t be the last. It shows what can be done when politicians from different parties work together in the national interest. Huge plaudits to my @scotgp & Labour co-petitioners #ScottishCase #Art50— Joanna Cherry QC MP (@joannaccherry) December 10, 2018
Jolyon Maugham QC, director of the Good Law Project which took the case to the court, said that the ruling was "arguably the most important case in modern domestic legal history".
"It is up to MPs to remember what they came into politics for and find the moral courage to put the country's interests before private ambition," he added.
Scotland's First Minister Nicola Sturgeon - who backed Remain - said the ruling meant it was "now open to the House of Commons" to extend Article 50 to allow time for another vote.
And Lib Dem Brexit spokesman Tom Brake tweeted that it was the "best news possible" and said it was now "full steam ahead for a People's Vote".
What about their critics?
Environment Secretary Michael Gove, a prominent Brexiteer, told BBC Radio 4's Today programme those calling for a second vote were "people who never accepted that first vote, who didn't accept that democratic mandate and who want to overturn it".
"We don't want to stay in the EU. We voted very clearly, 17.4 million people sent a clear message that we want to leave the European Union, and that means also leaving the jurisdiction of the European Court of Justice," he added.
"So, this case is all very well, but it doesn't alter the referendum vote or the clear intention of the government to make sure that we leave on 29 March."
"This case is all very well but it doesn't alter the referendum vote" says Environment Secretary @michaelgove on the news that the UK can unilaterally cancel Brexit, according to the European Court of Justice #r4Today https://t.co/gwnaJVD8H5 pic.twitter.com/dPvCw8Q7Hz— BBC Radio 4 Today (@BBCr4today) December 10, 2018
Foreign Secretary Jeremy Hunt told the BBC people would be "shocked and very angry" if any government delayed leaving the EU and it was "certainly not the intention of the government".
Brexiteer Tory Jacob Rees-Mogg hailed the decision as the right one, but told LBC radio: "I think this government would find it very difficult to remain the government if it went away from what it said in its manifesto and the referendum result."
What does the EU say?
A spokeswoman for the European Commission said it would "take note" of the judgement, but there was an "agreement on the table".
"As President [Jean-Claude] Juncker said, this deal is the best and only deal possible. We will not renegotiate," he said.
"Our position has therefore not changed and as far as we are concerned the United Kingdom is leaving the European Union on the 29 March 2019."
How does the ruling affect the meaningful vote?
BBC Brussels correspondent Adam Fleming said the ruling made staying in the EU "a real, viable option" and that may "sway a few MPs" in the way they vote.
But he said "a lot would have to change in British politics" to see the UK remain in the EU, with Mrs May and the government having to change its mind to make it a "political reality".