Holyrood would be handed a raft of new powers if the UK votes to leave the EU, a leading academic has said.
Prof Drew Scott said powers over areas such as fishing and farming that are currently wielded by Brussels would automatically default back to Holyrood.
He said this would create a "significant constitutional debate" about how these new powers should be exercised and paid for.
All five parties in the Scottish Parliament back EU membership.
But there are some dissenting voices within the parties.
UK Prime Minister David Cameron has travelled to Brussels, where he will attempt to agree a deal on changes that will pave the way for the UK's in/out referendum.
So far, much of the debate in Scotland about the impact of a possible UK exit from the EU has focused on the prospect of it triggering a second Scottish independence referendum.
The current devolution arrangement means that some matters are declared as being reserved to Westminster, with everything else being handed to the Scottish Parliament.
As long as the UK remains a part of the EU, many of the devolved powers - including environment, agriculture, fisheries and social policy - are guided by EU law.
But Prof Scott, who advised the Scottish government ahead of the independence referendum in 2014, said: "If the UK leaves the EU, then by default these powers will come back to the Scottish Parliament, not to the UK.
"That would create, in my view, a significant constitutional debate about how these powers should be exercised, how the policies should be paid for and how the relationship between the two governments will proceed".
He said half of the EU's budget currently goes on agriculture, "so you are talking about a significant amount of money".
"Agriculture has been reformed really since devolution and what we have seen is the Scottish Parliament has had more competence over the implementation of agricultural policy in Scotland, albeit it is still governed at EU level", he said.
"If it were to be the case that Britain left the EU, competence for farming would come back to the Scottish Parliament, full stop.
"It would have to be financed, so a new financial deal would have to be agreed between Edinburgh and London to pay for farming, which of course is not at all included in the current Smith negotiations or anything preceding that."
Prof Scott stressed he was not suggesting that people should vote to leave the EU in order to secure greater powers for Holyrood.
But he said Brexit would reopen the devolution settlement that was reached ahead of the Scottish Parliament opening in 1999, which was based on the country having EU membership.
Prof Scott said the current arrangements mean that the UK government currently has influence over Scottish environmental policy via Brussels.
He added: "That influence over environmental policy would disappear if we were to leave the EU, which would mean that Britain would find itself with Scotland perhaps diverging perhaps even further from UK policy.
"Now there is nothing wrong with that - that was what devolution in a sense was designed to do - but it would create inter-governmental discussions that would have to, I think, deal with some problematic issues".
Prof Scott said there were no easy solutions to those issues, but there were a number of possible legal solutions.
For example, the Scottish Parliament could decide to adopt all EU law over all matters and not change anything.
But he said: "That would still leave the thorny question of who pays for it, because if Scottish policy towards farming or fishing or regional economic development were to diverge from the UK, then the UK may say 'why are we paying for your more indulgent policy? We will pay you the rate we pay for the rest of the UK policy'.
"So we end up, perhaps, in a struggle about finances yet again."