Nicola Sturgeon has issued a warning to Boris Johnson over a second independence referendum, as the SNP ended up one seat short of an overall majority in the Scottish parliament.
Ms Sturgeon said another referendum "is the will of the country" and the prime minister would be "picking a fight with the democratic wishes of the Scottish people" if he tries to block it.
"You will not succeed, the only people who can decide the future of Scotland are the Scottish people," she said.
She added that the timing of another referendum "should be a matter for the Scottish Parliament" and is "not a decision for Boris Johnson or any Westminster politician".
Ms Sturgeon said the people of Scotland "must have the right to decide our own future when the COVID crisis has passed", describing it as a "matter of fundamental democratic principle".
The SNP’s hopes of winning an overall majority have been dashed, but the party will be the largest party at Holyrood and will now enjoy an historic fourth term in office.
The SNP will have 64 seats in the new parliament, followed by the Scottish Conservatives on 31, Scottish Labour on 22, the Scottish Greens on 8 and the Liberal Democrats on 4.
A total of 65 seats were required for an overall majority, but the Scottish Greens give an overall pro-independence majority of 72.
The Scottish Conservatives matched their best ever performance to hang on to all their seats, but Labour registered its worst performance in Scotland since devolution.
Ms Sturgeon said the SNP had "won more votes and a higher share of the votes in the constituency ballot than any party in the history of devolution", describing this as an "extraordinary and historic achievement".
It sets the stage for a battle between Holyrood and Mr Johnson’s government in Westminster over a second referendum.
The SNP has vowed to introduce legislation for another vote, but this could be challenged by the UK government in court.
Ms Sturgeon said that if Edinburgh’s request for a referendum is rejected, it will "demonstrate conclusively that the UK is not a partnership of equals and that – astonishingly – Westminster no longer sees the UK as a voluntary union of nations".
She added: "That in itself would be a very powerful argument for independence."
Ms Sturgeon has previously argued that winning more than half of the seats in the Scottish Parliament would give her a mandate to hold another vote.
But opponents will seize upon the SNP’s failure to win an outright majority.
Foreshadowing such an attack, the PM said on Friday that it was his impression that voters had "moved away from the idea of a referendum".
Speaking before the final results were declared, Ms Sturgeon had said the SNP failing to win a majority would not be a "huge surprise".
"I’ve said all along a majority was a long shot. We have a PR system in Holyrood, it’s not meant to deliver majorities. But I’m thrilled with our results," she said.
Sturgeon has dialled up the rhetoric and put the ball in Johnson’s court
Analysis by Joe Pike, political correspondent
A constitutional clash is now inevitable: standby for yet another battle between the Scottish and UK governments as Nicola Sturgeon pushes for a second independence referendum. Tonight she dialled up the rhetoric and the pressure. Boris Johnson will need to make the next move.
Ms Sturgeon’s victory in Scotland is historic in multiple ways. But she still fell short of the SNP majority she craved, and which she argued would give her the mandate for another vote on leaving the UK. That will be a relief for the prime minister.
More than half of Holyrood’s new MSPs will still back independence (if you add the SNP and the pro-indy Scottish Greens), and that group is likely to be slightly larger than in the last parliamentary session.
Yet Boris Johnson will be relieved that the nationalists were unable to secure the SNP majority they won in 2011, which led to the 2014 referendum and 55% backing for remaining part of the UK.
At this Holyrood election, turnout was up, as was tactical voting – in particular pro-union Scots choosing the party with the best chance of beating the SNP.
Scotland remains split on the central issue of the constitution: almost 50/50. There seems little sign that divide will be bridged anytime soon.