Sir David Edward said the nation would be a "negotiation state" rather than a "succession state", and insists EU rules would bind all sides to act in good faith.
Nationalists seized on his comments on the potential consequences of a vote for independence.
Sir David argues that the EU and many of its states owe their existence to self-determination. He mocks the prospect of "Scotland, its citizens and its land and seas" being left in legal limbo, and the notion of "a midnight hour at which all relationships would come to an end".
Deputy First Minister Nicola Sturgeon said: "This is a hugely welcome contribution to the debate on Scotland's future in Europe from one of the leading experts on the subject, not just in Scotland but anywhere in the Continent.
"Sir David's view that negotiations on Scotland's continued European Union membership will take place before independence concurs with the Scottish Government's position. And his opinion that Scotland's continued EU membership will require a treaty amendment – not an accession treaty – also coincides with our position, especially given that Scotland by definition already meets the EU entry criteria.
Scottish Conservative leader Ruth Davidson said: "This point of view does not echo what Alex Salmond and indeed the Yes campaign have been saying.
"Desperate attempts to pretend it does shows just how far they will go to con the people of Scotland on this issue. What Sir David Edward is saying is there will have to be negotiation."
Blair Jenkins, chief executive of Yes Scotland, said: "This is an extremely significant contribution from Scotland's foremost expert in EU law. It counters misleading claims that somehow Scotland would be expelled from the EU on independence."
Sir David, emeritus professor at Edinburgh University, wrote on an academic website: "Until the moment of separation, Scotland would remain an integral part of the EU; the Scottish people and all EU citizens living in Scotland would enjoy all the rights of citizenship and free movement; and the same would apply, correspondingly, to all other EU citizens and companies in their relations with Scotland."
l Charities are reluctant to enter into the independence debate for fear of being seen to take sides, the Carnegie UK Trust has said in a report.