Scotland has voted in favour of the UK staying in the EU by 62% to 38% – with all 32 council areas backing Remain.
But the UK as a whole has voted to Leave – raising the prospect of Scotland being taken out of the EU against its will.
First Minister Nicola Sturgeon said Scotland had delivered a “strong, unequivocal vote” to remain in the EU.
Leave has built an insurmountable lead in the race – with the BBC forecasting a win for Leave by 52% to 48%.
Ms Sturgeon’s predecessor, Alex Salmond, said the result could lead to a second independence referendum.
The SNP manifesto for May’s Scottish Parliament election said there should be another referendum if there was a “significant and material” change in circumstances, such as Scotland being taken out of the EU against its will.
Mr Salmond told the BBC he was “quite certain Nicola Sturgeon would implement the SNP manifesto”.
Glasgow voted by 168,335 (67%) to 84,474 (33%) in favour of Remain, although
turnout was relatively low.
Edinburgh backed Remain by 187,796 (74%) to 64,498 (26%), but results in England and Wales were much better for Leave.
Leave is more than a million votes ahead of Remain, with the English shires and Wales voting strongly in favour of Brexit.
UKIP’s Nigel Farage said: “Dare to dream that the dawn is breaking on an independent United Kingdom.”
The pound has fallen to levels not seen since about 1985
Turnout in Scotland was 67% while in Wales it was 72% and in England 73%.
Turnout was 56% in Glasgow and 63% in Dundee
Scottish Conservative leader Ruth Davidson has insisted the Tories will ‘stay together’ regardless of the result. Ms Sturgeon said the vote had made clear “that the people of Scotland see their future as part of the European Union”.
She added: “We await the final UK-wide result, but Scotland has spoken – and spoken decisively.”