BREXIT could be expanded into a “package deal” that lets an independent Scotland stay in the EU as well as allowing the UK to leave it, according to an expert on European law.

Dr Merijn Chamon also says the SNP government should hold an independence referendum as soon as the UK embarks on Brexit to get the best deal from Brussels.

He said the untried Brexit procedure, known as Article 50, could be adapted to include a newly independent Scotland remaining in the EU - instead of leaving temporarily and rejoining as a new applicant - and could help it keep some of the UK’s opt-outs.

The UK currently has opt-outs from the euro, the passport-free Schengen travel area, the charter of fundamental rights, and justice and security issues.

Once the next Prime Minister invokes Article 50 it starts a two-year countdown to Brexit during which the UK will negotiate exit terms with other EU states.

Nicola Sturgeon has said Brexit, despite Scotland voting against it, has made a second independence referendum “highly likely” in those two years.

Dr Chamon, of the Ghent European Law Institute in Belgium, told the Sunday Herald the SNP government should hold a referendum right away to get the time and authority to negotiate optimal membership terms with the EU.

A swift Yes could also help Scotland avoid the usual EU entry process, known as Article 49, which would mean starting from scratch, with no opt-outs and a commitment to the euro.

He said: “Once the Prime Minister gives the Article 50 notification, then I think the Scottish Government would have a good reason to say, ‘Now we hold [a referendum]’. I would do it as fast as possible after the Article 50 notification.

“If people vote for independence, then the Scottish Government would have a very clear mandate to go to Brussels and other member states and demand the Article 50 procedure does not simply deal with the UK, but deals with the Scottish situation as well.

“If the referendum is pro-independence then the Scottish Government simply presents a fait accompli to the member states. Basically, you end up in a situation where you cannot keep Article 50 simply for getting the UK out, you’re obliged to make a bigger package deal. In the ideal situation for Scotland, you don’t need Article 49, you just do it using Article 50.”

He said that because Brexit was unprecedented Scotland could credibly push for a bespoke deal.

“The fact is that, in the law, we don’t have anything prescribed for the Scottish situation. We have Article 50 that says you can take a state out but there is no procedure for a part of a member state becoming a member state in its own right, or for part of a member state to retain membership while the rest of the state leaves the EU. So you could adapt Article 50.”

He said a deal would ultimately come down to politics, with agreement needed from the rest of the UK and a consensus among the other 27 EU member states.

He said Scotland’s starting position with the EU would naturally be to keep all the UK’s opt-outs, but some would inevitably be negotiated away, including possibly the euro opt-out.

However he said Sweden had also committed to adopting the euro, but had avoided it by the simple “trick” of not going through the preliminary stage of eurozone membership.

“It’s one of these symbolic issues, but the politicians can be very pragmatic,” he said.

His comments echo those of Dr Kirsty Hughes, a former senior adviser in the European Commission, who last week said an early independence referendum was “logical”.

A Scottish Government source said: "This is an interesting contribution. Many key players in ?Europe are indicating they are open to finding a solution for Scotland. If an independence referendum is the chosen route then this suggestion, or something like it, may well come into play."