A devolved Scotland may effectively stay in the EU even if the rest of the UK backs Brexit, a think tank believes.

The country could not be a member state of the bloc without becoming independent, stresses the Brussels-based Friends of Europe in a major new paper.

But Scotland, the think tank argues, could both stay in the UK and forge a new and "differentiated" relationship with the EU across swathes of policy areas.

This unprecedented arrangement, suggests the FoE, could allow the nation to keep many current benefits of membership without splitting from the rest of the UK.

But it could also present political, constitutional and legal headaches of such gravity that they would provoke a British veto.

Westminster, for example, may not be prepared to see EU law continue to apply in Scottish courts but not in the those of the rest of the UK.

The prospect is just one of four scenarios set out by expert Kirsty Hughes as potential consequences of England voting to leave the EU and Scotland deciding to stay.

The others would see Scotland:

* leave the EU with the rest of the UK;

* call a rapid second independence referendum with the aim of "staying seamlessly" in the bloc;

* Or "challenge, block and stall" the Brexit process, sparking a constitutional crisis.

The report came as Scottish Labour signalled it would not campaign alongside other pro-EU parties and David Cameron met rightist Hungarian premier Victor Orban as he sought allies for his proposed EU reforms.

Nationalists have long hinted that Brexit could trigger a second independence referendum.

Dr Hughes said: "The route to independence would in many ways be made much more complex and difficult if the UK votes for Brexit, while Scotland votes to remain in the EU.

"Yet while some pro-independence voices in Scotland caution against rushing into a second independence referendum in the face of Brexit, the challenges for Scotland if it, along with the rest of the UK, leaves the EU, mean that a rapid push for independence could make strategic sense."

After all, she said, Scotland could end up delaying independence and finding itself outside both the UK and the EU.

Equally the prospect of an EU frontier across the island of Britain, Dr Hughes suggests, could put other voters off independence.

But Dr Hughes believes there could be a compromise, with Scotland retaining closer links with the EU than England, Wales and Northern Ireland.

There is no direct precedent. But the bloc and member states have taken similarly flexible approaches before.

Denmark is in the EU but the Faroe Islands, which are part of Denmark, are not and have negotiated a special relationship with the bloc.

And the whole of Cyprus is in the EU, including the Turkish-speaking northern part of the island that is not administered by the Republic of Cyprus, the bloc's member state.

She said: "Scotland could argue it wanted to secure or keep closer relationships with the EU, for example, on climate policy, energy, fisheries, agriculture or education.

"Brussels might be open to such a creative solution, though that would not be guaranteed.

"But the big question would be whether the UK government would be open to discussing this or would veto it?

"Clearly, the more the Scottish government can do to keep Scotland

in line with EU laws and policies, the easier it would be in the future for an independent Scotland to re-join the EU, and equally the more the costs of Brexit for Scotland could perhaps be reduced."

John MacDonald of the Scottish Global Forum first raised the prospect of a devolved Scotland somehow staying in the EU after a Brexit some years ago.

He said: "There is no shortage of people who want to say this can't happen. But the way in which the Faroe Islands engages with the EU represents a good example of what might be possible for Scotland."

More reading: What if Scotland left the European Union?