She met President Michael D Higgins, brought Senators to their feet in acclamation, had politicians lining up for selfies and was greeted like a rockstar wherever she went. Scottish journalists who accompanied Nicola Sturgeon on her two-day visit to Dublin this week marvelled at the warm reception she received.

“Even Ms Sturgeon could not have hoped for the response she got from the Senators, who appeared to be trying to outdo one another in their praise for her and her cause of Scottish independence,” wrote ITV’s Peter MacMahon. “One after the other the members of the Upper House – from all parties and none – got to their feet to express the hope that Scotland would be joining Ireland as a small independent country very soon.”

So swept up by the separatist mood was the leader of the Seanad, Jerry Buttimer of Fine Gael, that, as MacMahon noted, he twice referred to Sturgeon as the first foreign “head of state” to address the chamber. Perhaps to spare the blushes of the British ambassador, who was looking on from the public gallery, the diplomatic guardians of the official Seanad record quietly intervened and changed Buttimer’s slip to “head of government” in the transcript.

Diplomatic manoeuvring

More serious diplomatic manoeuvring underlay Sturgeon’s entire trip – her first to Dublin since becoming first minister in 2014. Strengthening economic links between Scotland and Ireland, an area the Scottish government has been working on assiduously in recent years, was the ostensible purpose, along with a broader desire to build closer political connections between Dublin and Edinburgh. But behind all of this is the spectre of Brexit and the positioning going on in key capitals ahead of the complex round of negotiations on the horizon.

Brexit presents Dublin and Edinburgh with specific problems both governments will have to grapple with for years. For the Republic, concern centres on the future of the Border, the peace process and the Irish in the UK as well as the loss of an important ally at the EU table. Sturgeon’s administration, meanwhile, must ensure Scotland’s interests are protected in a situation where it is likely to be taken out of the EU against its will after a process in which it may not have any formal role.

For Edinburgh, an open channel of communication to Dublin is more important than ever. Even before the Brexit referendum, the Holyrood government has often struggled to get direct access to EU discussions on issues, such as agriculture or fisheries, where its crucial national interests are at stake. That problem will be magnified by Brexit, where the stakes are higher still.

“It’s very unclear to what extent Scotland will even be getting the information coming out of London-Brussels talks, or even internal London talks,” says one Government figure. “She and her government would see it as important in the long run to have a good strong channel of communication to Dublin in order to get information and a sense of what’s on the table.”

Broad sympathy

The Government has made a point, since the Brexit referendum, of raising Scotland’s concerns. At the first European Council after the British vote, Taoiseach Enda Kenny in effect acted as a surrogate for the absent Sturgeon. “I think the Scots are clear that Ireland is positive. The relationship is very good,” says a senior official. There is broad sympathy for the Scots, who are seen as having been thrown into a difficult situation not of their making and having to deal with a London government that is itself struggling to keep its head above water.

However, Dublin is aware of how unpopular its advocacy for Edinburgh has been in London, and one of the concerns for some on Merrion Street in advance of Sturgeon’s visit was that she would publicly press Dublin to endorse the principle of Scotland remaining in the EU, which is SNP policy (Sturgeon herself has focused on the objective of continued membership of the single market). For Dublin to do that, according to a second Government official, would bring it uncomfortably close to taking a position on Scottish independence – something studiously avoided doing during the independence referendum campaign in 2014. “The UK is still a constituent part of the UK,” says the official. “We cannot say we support independence.”

Transformed debate

That may be for another day. A common view in Government is that if the Brexit negotiations produce a deal that Edinburgh cannot endorse, the independence debate will be transformed (“If they’re not happy with the deal the UK gets, Scotland is gone,” says one Government figure”). Sturgeon did not seek Dublin’s support on the idea of retaining its EU spot, but she did put down important markers. Officials noted how often she talked about Northern Ireland’s position, in particular the border, and Dublin was grateful for her support on its key concerns.

Among key Brexit-watchers in Government, it makes sense for Sturgeon to draw parallels between Scotland and the North. “Their strategy [in Scotland] will be to point to areas where Scottish interests coincide with and are identical to Irish or Northern Irish interests,” says a third senior figure. “There is a similarity in the fact that Scotland and Northern Ireland voted to remain, that Scotland and Northern Ireland have a relationship with the UK but also a crucial relationship with the EU.

“If a Dublin government is going to bat with Northern Ireland’s interests at heart, [the Scots will ask] that we would be cognisant that that also equates to Scottish interests.” To that extent, Scotland’s priority now is similar to the Government’s. Since the referendum, Kenny and Minister for Foreign Affairs Charlie Flanagan have made a concerted effort to stress specific Irish concerns to each EU leader in turn. Hence the succession of visiting dignitaries who have been brought out for the cameras to say they recognise Ireland’s “unique position” in the Brexit talks.

Beyond the specific economic and diplomatic goals of Sturgeon’s visit, some Scottish observers stressed how the first minister’s reception in Dublin helped serve domestic political imperatives as well. According to the journalist Jamie Maxwell, writing in the magazine Bella Caledonia, it reflected a new international assertiveness. “For nationalists, the last two days have reinforced the sense that Holyrood is an independent, or at least semi-autonomous, actor on the global stage,” he wrote.