The European Court of Justice (ECJ) has ruled the UK can unilaterally revoke its withdrawal from the EU.

The judgement came ahead of Tuesday's crunch vote at Westminster on the Prime Minister's Brexit deal.

The case to decide whether an EU member state such as the UK can decide on its own to revoke the Article 50 withdrawal process was brought by a cross-party group of Scottish politicians.

They are Labour MEPs Catherine Stihler and David Martin, Joanna Cherry MP and Alyn Smith MEP of the SNP, and Green MSPs Andy Wightman and Ross Greer, together with lawyer Jolyon Maugham QC, director of the Good Law Project.

They argue unilateral revocation is possible and believe it could pave the way for an alternative option to Brexit, such as a People's Vote to enable remaining in the EU.

However, legal representatives for the UK Government believe the case is inadmissible as it deals with a hypothetical situation, since the government's policy is not to revoke Article 50.

Lawyers representing the Council of the European Union and from the European Commission meanwhile argue that revocation is possible but would require unanimous agreement from all member states.

Speaking to STV News, First Minister Nicola Sturgeon said: "The European Court of Justice ruling is great news.

"It sets out very clearly a path to stopping Brexit: extension of Article 50 to give time for another vote, and then, if that vote results in a decision to remain, Article 50 can be unilaterally revoked by the UK.

"So, clearly now it's not a choice between Theresa May's bad deal and no deal - there is an alternative, and that's an alternative path that I hope is taken."

She added: "After two and a half years where the UK Government and Brexiteers have failed to deliver any kind of Brexit that protects the vital interests of the UK, it's an opportunity to do the right thing, and to give people the opportunity given everything they know and everything that has changed in the circumstances over these last two and a half years, to remain in the EU.

"It's a good moment and a good day for those of us who want to see the UK and Scotland stay in the EU."

Scotland's constitutional relations secretary Michael Russell,said: "This is a hugely important decision that provides clarity at an essential point in the UK's decision-making over its future relationship with the EU.

"People in Scotland overwhelmingly voted to remain in the EU and that continues to be the best option for Scotland and the UK as a whole.

"This judgement exposes as false the idea that the only choice is between a bad deal negotiated by the UK Government or the disaster of no deal.

"We now know, thanks to the efforts of Scotland's parliamentarians, that remaining in the EU is still on the table."

On Thursday, the UK Supreme Court will rule on if the Scottish Government's emergency Brexit Bill, passed in March, is within the Scottish Parliament's competence after a legal challenge by UK ministers.

The legislation was tabled to safeguard devolution as powers come back from the EU, with the Scottish and UK governments in dispute over devolved powers post-Brexit.

It was designed as an alternative to the UK's own Withdrawal Bill, which the Scottish Parliament formally refused to give its consent to.