Moray has supported the UK’s European Union membership – but only by 122 votes.
The region’s Remain camp secured 50.1% of the ballot, with 24,114 votes to Leave’s 23,992.
Perhaps unsurprisingly, the result was met with relief rather than jubilation by the Remain supporters who had gathered at Elgin Town Hall.
Campaigners who had spent months trying to convince residents that Moray would be better off outwith the EU said their 49.9% share “made a statement”.
The region’s SNP group spearheaded the Remain campaign.
Following the result, Moray MSP Richard Lochhead praised the narrow majority of the electorate who opted not to sever the UK’s ties with Brussels.
But the Nationalist politician conceded that the result “could not have been closer”.
Mr Lochhead said: “Moray has spoken, and has voted to continue EU membership.
“That will bring our communities and businesses a great deal of benefits.
“But clearly, a lot of people have expressed some very serious concerns about the European Union.”
The MSP said the close result illustrated the importance of every vote cast during Thursday’s referendum.
Moray’s leading Leave campaigner, Paul Briggs, referred to the night as a “rollercoaster”.
Mr Briggs said: “It was such a slim majority for staying in.
“People in Moray have reacted against a downturn in fishing and agriculture, that they believe European Union regulations are responsible for.
“This has been a really emotional night for me and the other Leave supporters, at some points it looked like we were going to clinch it.”
The Leave group added that their effort was most robustly supported by the area’s coastal communities.
Voters in Buckie, Lossiemouth, Burghead, Hopeman and Cullen were reported to have backed departing from the union by a two-to-one swing at some polling stations.
However, seaside residents in Findhorn turned out so strongly in favour of Remain that pundits believe their ballots were crucial in securing the referendum win.
Voting closed at 10pm, and less than 10 minutes later the first of the boxes, from Elgin’s Mansefield Hotel, arrived at the hall.
The count went on until shortly after 2am, when Moray Council counting officer Mark Palmer took to the venue’s stage to reveal the outcome.
Overall, 48,139 votes were cast from an electorate of 71,370 – representing a turnout of 67.4%.