Scotland has voted resoundingly to stay in the EU, with a final result of 62% for Remain and 38% for Leave.
All 32 council areas in Scotland declared victories for Remain.
But in the UK, ITV have predicted a win for the Leave campaign, which is around 800,000 votes ahead of Remain, although counting is still ongoing.
The final turnout in Scotland was 67.2%, with the highest Remain votes declared in East Renfrewshire and Edinburgh, at 74% each.
The tightest Scottish contest was Moray, which saw Leave lose by only 119 votes, on 49.9%.
Stirling, Perth & Kinross, Aberdeen, and Dundee all saw Remain votes of 60% or higher.
In Glasgow, Scotland's most populous city, two-thirds of voters backed the Remain side - but on a turnout of only 56%.
With the UK result so close, Remain campaigners were hoping cities like London, Manchester and Liverpool with large pro-Remain majorities would tip the balance in their favour.
However, the Leave campaign has won significant victories in Birmingham, northern England, Yorkshire and Wales, and are maintaining a slim national lead.
The final national result is to be announced by the chief counting officer in Manchester later on Friday morning.
It is expected the winning campaign will have a vote total in excess of 16.5 million by the time the final result has been declared.