All 32 voting areas in Scotland voted to stay in the European Union, but they were outnumbered by an overwhelming ''Leave'' vote in England and Wales.
That has created an immediate political dilemma for Scotland, which in a referendum in September 2014 voted against secession from the United Kingdom.
Scotland, which has been legally in union with England and Wales since 1707, is considered the most pro-European part of the United Kingdom, and the decision by British voters to leave the 28-member European Union could prompt a second independence vote.
Scotland's first minister, Nicola Sturgeon, said her country cast an ''unequivocal'' vote to remain in the European Union, declaring before 5 am that ''the vote here makes clear that the people of Scotland see their future as part of the European Union.'' On Twitter, she declared a ''clean sweep'' for Remain.
The author J K Rowling of Harry Potter fame, one of many celebrities who had backed remaining in the European Union, was quick to predict that the United Kingdom would break up - and she blamed Prime Minister David Cameron.
''Scotland will seek independence now,'' she wrote on Twitter. ''Cameron's legacy will be breaking up two unions. Neither needed to happen.''
Scotland rejected independence from the United Kingdom in its own referendum in 2014, but the result on Friday gives new momentum to the cause.