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 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 favor, 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.
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.
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.
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.
A spokeswoman for the European Commission said it would take note of the judgment, 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, she 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.