Image copyright ECJ Image caption The case was heard by the full court of European judges last week

The UK should be able to unilaterally cancel its withdrawal from the EU, according to a top European law officer.

The non-binding opinion was delivered by an advocate general of the European Court of Justice.

A group of Scottish politicians has asked the court whether the UK can call off Brexit without the consent of other member states.

The Court of Justice (ECJ) will deliver its final ruling at a later date.

The advice from advocate general Manuel Campos Sanchez-Bordona comes as the House of Commons begins five days of debates on Prime Minister Theresa May's proposed Brexit deal, with a vote due to be held next Tuesday.

In a written statement, the ECJ said Mr Campos Sanchez-Bordona's opinion was that if a country decided to leave the EU, it should also have the power to change its mind during the two-year exit process specified in Article 50 of the EU treaty.

And it should be able to do so without needing the consent of the other 27 member states - contrary to what the EU itself has argued.

While the advocate general's opinions are not binding, the court tends to follow them in the majority of its final rulings.

The anti-Brexit politicians and campaigners who have brought the case hope it will give MPs an extra option when considering whether to approve Mrs May's draft deal or not, because it could keep alive the prospect of calling off Brexit - potentially through another referendum.

The ECJ statement said the advocate general had proposed that the Court of Justice should "declare that Article 50 allows the unilateral revocation of the notification of the intention to withdraw from the EU".

It added: "That possibility continues to exist until such time as the withdrawal agreement is formally concluded."

The UK is due to leave the EU on 29 March next year, but the deal negotiated with the EU has to be backed by a majority MPs if it is to come into force.

Welcoming the advocate general's opinion, SNP MEP Alyn Smith, one of those who brought the case, said it showed that "we now have a roadmap out of the Brexit shambles".

He said parliament was not necessarily facing a choice between accepting Mrs May's deal or leaving the EU with no deal, and that "there are other options, and we can stop the clock."

Who has brought the case?

Image caption A group of politicians brought the case including (from top left) Catherine Stihler MEP; Joanna Cherry MP; David Martin MEP; (from bottom left) Alyn Smith MEP; Ross Greer MSP and Andy Wightman MSP

A cross-party group of politicians and campaigners including Green MSPs Andy Wightman and Ross Greer, MEP Alyn Smith and MP Joanna Cherry of the SNP, and Labour MEPs David Martin and Catherine Stihler brought the case together with lawyer Jolyon Maugham QC, director of the Good Law Project.

They initially took it to the Court of Session in Edinburgh, which ultimately agreed to pass it to the ECJ.

Two attempts by the UK government to appeal against the referral to the European court were rejected, and the case was opposed by the government and the EU institutions in a hearing before all 27 ECJ judges last week.

Hubert Legal, the chief lawyer for the European Council, argued that allowing unilateral withdrawal could create "endless uncertainty" by allowing countries to announce they are leaving the EU in an attempt to secure better membership terms, before cancelling their withdrawal.

The UK government's lawyers argued that the case was purely hypothetical as "the UK does not intend to revoke its notification", and ECJ judges should therefore refuse to rule on it.

They added that the politicians behind the case wanted to use it as "political ammunition to be used in, and to pressure, the UK parliament".

Analysis by Clive Coleman, BBC legal correspondent

The advocate general's opinion that the UK has the right to unilaterally withdraw Article 50 notification of its intention to leave the EU flies in the face of what the UK government and the EU want.

Although the Advocate General's opinion is non-binding, the ECJ follow his opinions in the majority of cases.

The whole issue of revocation remains hypothetical at present because the government has made it clear there is no possibility of seeking to revoke the notice to leave the EU.

However, the statement raises the question of how the UK might revoke notification.

It would almost certainly need to be done by an act of parliament. If it was done by ministers alone using prerogative powers it would frustrate the will of parliament as expressed in the European Union (Withdrawal) Act 2018.

It should be noted that the statement and the case concerns revocation of notice to leave, and not a delay or extension of the two-year period provided for under Article 50.

That period can be extended, but only with the agreement of all of the other 27 EU states. Whereas extension of the Article 50 period could become a political necessity, revocation of Article 50 remains something of an academic point at present. However, that would change if there was a second referendum in which the British people voted to remain in the EU.