Now that Theresa May has been crowned Prime Minister, the Scottish Government will be waiting with bated breath to see how she chooses to define her relationship with Scotland. We already know she plans to ignore the 62 per cent of Scots who voted to remain in the EU by "making a success of Brexit", and that she opposes Scottish independence. But in addition to these two battlelines, we may add a third, equally explosive issue: immigration.

The Scottish Government and Mrs May have been at loggerheads over immigration for years. The SNP has denounced UK immigration policy as damaging to Scottish interests, preferring flexibility to meet labour-market demands. Mrs May’s response during the independence referendum campaign was to warn of "uncontrolled immigration" should Scotland join Schengen, alluding to the need for border posts along Hadrian’s Wall to keep immigrants (and Scots?) out of England.

Such arguments have taken on a darker hue since the EU referendum. A driving demand of First Minister Nicola Sturgeon (and Green Co-Convenor Patrick Harvie) is that the UK should immediately guarantee the status of EU nationals living in Scotland. However, Mrs May has refused to budge until a deal is made about Britons abroad, raising the possibility millions of EU nationals could be deported when the UK leaves the EU.

So where does that leave Ms Sturgeon’s government? Here I will try to sketch out some ways in which Scotland might protect the rights of its EU nationals.

Ms Sturgeon’s strategy so far has centred on soft diplomacy. This is understandable given immigration is reserved to Westminster. She has written letters to Mrs May and David Cameron urging them to assure EU nationals of their residency rights, and she’s likely using all the intergovernmental back channels at her disposal to influence UK policy. The next meeting of the Joint Ministerial Committee on Europe will also be used as a platform to air Scotland’s concerns over immigration. But what if Mrs May is – like Margaret Thatcher – not a woman for turning?

Another option is to unpick the Sewel Convention, whereby the UK Parliament “will not normally legislate in devolved areas without the consent of the Scottish Parliament”. While the residency of EU nationals in Scotland is not a devolved competence, their contribution to Scotland’s economic development is a devolved concern. Deporting EU nationals would have a significant detrimental effect on Scotland’s economy. And let’s not forget the Smith Commission’s clause that there should be "no detriment" to Scotland’s fiscal capacity as a result of UK Government policy decisions. However, Mrs May’s team could argue there is no detriment, or that EU nationals are not a devolved concern.

To which the SNP government may respond with more strident calls for full immigration control. Quebec provides a useful model, having signed an agreement with the government of Canada that allows it to choose its own immigrants according to its own rules. However, there are obstacles to this scenario in Scotland. While Michael Gove once argued Brexit would allow Scotland to wield more control over immigration through a regionalised points system, Mrs May – a perceived micromanager – will likely want to keep immigration policy firmly under the control of her old stomping ground, the UK Home Office.

If Mrs May is unlikely to give Scotland full control over immigration, might she agree to partial control? We have a precedent in the Fresh Talent Initiative of 2004-8, which enabled foreign students to live and work for two years after graduation. Could we imagine the creation of a European Talent Initiative that allows EU nationals to live in Scotland for, ideally, an indefinite period of time, or more narrowly, a period of five years, during which they can apply for citizenship? While Fresh Talent was negotiated during a period of relative harmony (with Labour ruling in both London and Edinburgh), the conditions are different now.

There is presently little goodwill between Edinburgh and London. And Mrs May’s record on immigration – which has been highly restrictive and often inflammatory (recall her "go home" vans) – is unlikely to endear her to the Scottish Government’s calls for a more liberal approach. Which means Ms Sturgeon’s best chance of protecting EU nationals may ultimately be to win another referendum on independence and apply for EU membership. Only then would Ms Sturgeon have control over who gets to stay in Scotland.

Dr Eve Hepburn is Senior Lecturer in Politics at the University of Edinburgh.