In quotes: Scotland votes Remain as UK backs Brexit
Scotland has voted in favour of the UK staying in the EU by 62% to 38% - but the UK as a whole has voted to leave.
Prime Minister David Cameron has responded to the historic decision by announcing he will step down by October.
Here's how some of the key figures in Scotland have been reacting.
Nicola Sturgeon, First Minister
The SNP leader said Scotland had delivered a "strong, unequivocal vote" to remain in the EU.
Speaking at a news conference in Edinburgh on Friday morning, she said the result meant that a second referendum on Scottish independence was "highly likely".
She said: "As things stand, Scotland faces the prospect of being taken out of the EU against our will. I regard that as democratically unacceptable."
She said the option of a second independence referendum was "now on the table" after the UK voted to Leave the EU.
"We will begin to prepare the legislation that would be required to enable a new independence referendum to take place if and when Parliament so decides," she added.
David Mundell, Secretary of State for Scotland
Reacting to the news that Mr Cameron will step down, Mr Mundell described him as "a great leader of my party and of our country".
He went on: "As the prime minister made clear this morning, the UK government is absolutely committed to working closely with the Scottish government to ensure they are fully involved in the negotiation process.
"The prime minister has already spoken to the first minister and I have today offered to meet with the Scottish government in Edinburgh to discuss next steps.
"The United Kingdom has fundamental strengths and this is a time for calmness and deliberation - not pushing other personal or political agendas."
Ruth Davidson, Scottish Conservative leader
Following Mr Cameron's announcement that he is to step down by October, Ms Davidson said: "His decision to remain in post over the short term is the right one, and will help ensure greater stability in the days ahead.
"It is right that he has already spoken to Nicola Sturgeon to ensure the Scottish government is involved in the negotiations that will follow."
Speaking later at a news conference, she said: "There can be no avoiding the fact that the days ahead will not be easy. We are being tested."
However, she said she did not believe that a second independence referendum was "in the best interests of the people of Scotland".
She added: "We do not address the challenges of leaving the European Union by leaving our own Union of nations, our biggest market and our closest friends.
"I believe in Scotland's place within the United Kingdom today as much as ever.
Alex Salmond, former first minister
Ms Sturgeon's predecessor, Mr Salmond, said the result could lead to a second independence referendum.
Speaking on BBC Radio Scotland, he said: "Nicola Sturgeon has to go forward with the manifesto, which as you remember said the Scottish Parliament should have the right to call a second referendum on Scottish independence if there was a material, significant change in circumstances like Scotland being dragged out of the European Union against the will of the Scottish people.
"Now that has happened, and I am certain Nicola Sturgeon will go forward on that manifesto commitment."
Tom Harris, campaign director for Scottish Vote Leave
The former Labour MP said: "We don't need a failing EU to hold our hand, we don't need to send millions every week to Brussels, and we don't have to accept uncontrolled EU migration.
"We can take back control."
He also told BBC Scotland that he guaranteed there would not be a second independence referendum after the EU result.
Kezia Dugdale, Scottish Labour leader
"I spoke to Nicola Sturgeon this afternoon. We both have profound disagreements about the constitutional future of Scotland, but I stand ready to work with her in the best interests of the people of Scotland," she said.
"Now is the time for calm heads. Labour's manifesto ruled out a second referendum in the lifetime of this parliament - we won't be changing our minds any time soon.
"One thing we know for sure is that we know very little about what will happen next.
"However, on the question of independence, many of the fundamental questions that were unresolved and unanswered in 2014, remain so. Not least the question of currency. What we don't need today is more turmoil, more upheaval and more economic chaos."
Willie Rennie, Scottish Liberal Democrat leader
Mr Rennie said he was "angry" that Scotland had lost its place in Europe.
"It is bad for our country and the people who live here. It means cutting our ties with our biggest economic market despite the consequences for trade, business, jobs and incomes," he added.
Mr Rennie said he was "embarrassed by the signal it sends to the rest of Europe and the rest of the world".
Patrick Harvie, Co-convener of the Scottish Greens
"It's devastating to see that the deceitful, manipulative and at times downright racist Brexit campaign has succeeded south of the border, and looks set to tear up the many benefits of EU membership and play fast and loose with our economic future," he said.
"The Leave campaign claimed to be defending democracy, but they now propose to remove the rights of EU citizenship from Scotland regardless of the way people living here voted."
The MSP called for cross-party action at Holyrood to protect Scotland from the result.
David Coburn, UKIP leader in Scotland
Scotland's only UKIP MEP said it was "fantastic" that "we're out".
He added: "Whatever nonsense Nicola is coming out with, all this nonsense of another referendum, another neverendum - she's talking through her hat - because 40% of the population don't want anything to do with the EU."
Donald Trump, US presidential hopeful
Speaking as he arrived for the opening of his hotel and golf resort in Ayrshire, the US billionaire said it was a "great thing" that the people of the UK had "taken back their country".
He tweeted: "Just arrived in Scotland. Place is going wild over the vote. They took their country back, just like we will take America back. No games!"
John Edward, Scotland Stronger In Europe
The senior spokesman for the Remain campaign in Scotland said: "We are proud that every single local authority area in Scotland voted Remain with an overall lead of 24 points over Leave - that clearly stands out as an exceptional result compared to the rest of the UK.
"We are pleased to have won well in Scotland, but of course the only result that decides the issue is the UK-wide vote."
David Frost, Scotch Whisky Association chief executive
He said the process of leaving the EU would "inevitably generate significant uncertainty".
He added: "Of course, we are confident Scotch whisky will remain the pre-eminent international spirit drink.
"But equally, there are serious issues to resolve in areas of major importance to our industry and which require urgent attention, notably the nature of future trade arrangements with both the single market and the wider world."
Mike Park, chief executive of the Scottish White Fish Producers' Association
He said most of his organisation's members had wanted out of the EU.
"European Union fisheries policy is flawed - that is why so many fishermen voted to leave," he added.
"But we need to recognise that there are significant dangers to the industry if the UK and Scottish governments do not react to the very clear message by focusing on a new approach that recognises fishermen themselves and their communities as the key stakeholders."
Allan Bowie, National Farmers Union of Scotland president
He said the result would mark a period of "great uncertainty for Scotland's farmers and crofters".
He added: "The vote for the UK to leave the European Union brings few certainties as to what will happen in the weeks and months ahead but an intense period of negotiation will begin and a negotiated exit from the EU is expected to take a minimum of two years.
"NFU Scotland will be at the centre of any discussions on new arrangements for our food and farming sector. There is a need for these discussions to commence quickly so that the many businesses who benefit from support from the CAP and value the markets we have established for our produce in Europe and further afield can plan for the future."
Grahame Smith, Scottish Trade Union Congress
The STUC general secretary described the result as "desperately disappointing".
He said: "The economic consequences are likely to be severe with a significantly detrimental impact on Scottish jobs and investment.
"With growth currently very weak and employment falling rapidly, the now unavoidable extended period of uncertainty is the last thing the Scottish economy needs."
He added: "We expect early discussions with the Scottish government over the economic and social impact of leaving the EU and its role in and approach to Brexit negotiations. There are many issues to consider not least our future trading arrangements and the status of the many and valued EU workers settled in our country."
Andy Willox, Federation of Small Businesses
The FSB's Scottish policy convenor, said firms would be looking to the Scottish and UK governments, and the Bank of England, to provide leadership.
"We welcome the prime minister's assurance that the Scottish government, and the other devolved administrations, will be fully involved in the negotiations associated with the UK's departure from the EU," he said.
"While questions about a second independence referendum will inevitably dominate the headlines, there are more immediate matters for small firms - from clarity over access to the single market to the free movement of people."
Liz Cameron, Scottish Chambers of Commerce
Said there was "mixed reactions" to the news that the majority of the UK had voted to leave the EU.
She said: "We would urge a level of calmness - our products and services will continue to be traded throughout Europe and beyond.
"The priority for Scotland now is for our governments and businesses to carry on and show great leadership in order to stabilise the markets and begin to plan our new relationship with Europe.
She added: "Businesses will also be looking to understand the potential advantages that the UK's exit from the EU might bring. In particular, we are keen to understand how governments in Edinburgh and London might be able to more explicitly support Scottish businesses to win local contracts from the public sector."
Vonnie Sandlan, NUS Scotland President
"This is an incredibly disappointing result, and one that Scotland clearly took a different stand against", she said.
"In the coming weeks and months it is vital that the UK government works closely with the devolved governments, and with all of us who stood up proudly for our EU membership ensuring we do all we can to stem the damaging consequences we know this result could have."
Reverend Dr Richard Frazer, Church of Scotland
The convener of the Kirk's church and society council said: "The UK has voted to leave the EU at the end of what has been, at times, a bitter and polarising campaign.
"I believe this is a decision which many people will regret.
"In Scotland, the majority voted differently and this will inevitably raise questions about Scotland's future in the rest of the UK. That is for another day."
He added: "The UK has made a momentous decision but it must not be construed as us pulling up the draw bridge. We are citizens of Europe and the world - and our future and the future of others is dependent upon us working together."
Eilidh Wiseman, Law Society of Scotland
The society's president said: "The vote to leave the EU marks the start of monumental change for the UK and our relationship with the rest of Europe.
"While we cannot predict the full economic effects of the vote to leave on business decisions of law firms or those of their clients, it's important to understand that the UK remains a full member of the EU until the terms of our withdrawal agreement are negotiated.
"There will be no immediate change to the current legal position so solicitors' day to day practice and the advice they provide for clients won't yet be affected."
Angus Robertson, SNP Westminster leader
Speaking on BBC Radio Scotland, he said people in Scotland had been "totally mislead" by those backing a "No" vote in the Scottish independence referendum in 2014.
"They were told to vote against Scottish independence because otherwise we would find ourselves outside the European Union," he said.
"How ironic that the very same people, many of them campaigning with Nigel Farage, are the people who are dragging us out of the European Union today. I think that is more than disappointing, it is democratically unacceptable."
JK Rowling, author
The Harry Potter writer had previously come out in support of the Remain campaign.
She tweeted: "Scotland will seek independence now. (David) Cameron's legacy will be breaking up two unions. Neither needed to happen."