The BBC’s Scotland editor James Cook considers how history will judge her years in office.
Nicola Sturgeon will be remembered as one of the most impressive politicians of her generation, delivering a string of landslide election victories for the SNP.
But the first minister entered politics for one thing above all others and, in the end, she failed to deliver it.
As she pointed out herself in her resignation speech, she has been campaigning for Scottish independence since she was a teenager in Ayrshire in the 1980s.
Ms Sturgeon once told me that it was Margaret Thatcher, Conservative prime minister throughout that turbulent debate, who had pushed her into politics.
The picture the Scottish National Party leader painted of the nation of her youth was bleak, a world of dying industry and fading spirit.
Mrs Thatcher, she said, had created a sense of “hopelessness” by presiding over the decline of coal, steel and shipbuilding.
“You had the prospect of leaving school and maybe never getting a job,” said Ms Sturgeon.
Back then it was not the pro-independence SNP which dominated Scottish politics but Labour.
The party had built a power base which helped propel Tony Blair and Gordon Brown into Downing Street in 1997, delivering devolution of powers to Cardiff and Edinburgh.
When the new Scottish Parliament opened in 1999, the idea that the SNP would be in charge within a decade would have been dismissed by many as absurd.
But under Alex Salmond, with Ms Sturgeon at his side every step of the way, the nationalists not only won power as a minority government in 2007 but went even further four years later, securing a majority at Holyrood which led to a referendum on independence.
In September 2014, Scotland voted to remain in the union by 55% to 45%. When, within hours, Mr Salmond resigned there was no doubt about the identity of his successor and no doubt that she represented continuity in the party.
At the time Ms Sturgeon was fulsome in her praise, describing Mr Salmond as her “friend, mentor and colleague,” and adding, “Quite simply, I would not have been able to do what I have in politics without his constant advice, guidance and support through all these years.”
That relationship would break down in spectacular fashion once Mr Salmond was charged with sexual assault and harassment. He was acquitted of all the charges at the high court in Edinburgh.
The trial was bruising for all involved. There were revelations about late night drinking with female staff members in the bedroom of the first minister’s official residence, Bute House. His own lawyer accepted that Mr Salmond could have been a better man.
But the episode also had a political effect, with Mr Salmond ultimately creating a rival party, Alba. Although his outfit did not break through with the electorate, it was at times a thorn in the side of his successor.
In the early days of her leadership, though, it had seemed Ms Sturgeon could walk on water. The popularity of the first woman to hold the job of first minister was at times extraordinary.
In the UK general election of 2015 the SNP swept almost all before it, securing 56 of the 59 Scottish seats at Westminster.
Ms Sturgeon embarked on a tour of giant venues, feted by adoring fans.
Behind this personal popularity lay a profound electoral shift.
Many working class voters in Labour’s old post-industrial heartlands had switched allegiance to the SNP.
The party’s membership soared but this was a challenge as well as a blessing. Many of the new members were impatient — demanding another crack at independence immediately.
Ms Sturgeon did not regard that as realistic, preferring instead to focus on proving that her SNP could govern effectively while gradually building towards a sustained, clear majority in favour of independence.
In June 2016 Brexit scrambled that calculus.
Scotland voted to remain in the European Union by 62% to 38% but was forced to leave anyway because the UK as a whole had opted to quit the trading bloc.
For Ms Sturgeon, enduring years of Tory government which Scotland had voted against was bad enough, but this was worse.
Brexit, she said was a “material change” which merited a second referendum on independence.
And yet she was ultimately unable to deliver that vote. Ms Sturgeon may have seen off four Tory prime ministers but the fifth, Rishi Sunak, will be able to say that he saw off the threat she posed to the union.
So why is she going now, with her core business unfinished?
There is quite a long list of possible reasons.
Governing is hard. Nicola Sturgeon has failed to keep her promise of closing the educational attainment gap between richer and poorer pupils although she is keen to stress her record on ensuring that more deprived students can go to university.
In common with other parts of the UK the NHS is in dire straits but devolution means this is Ms Sturgeon’s responsibility north of the border.
There are also problems with issues as wide ranging as ferry services and social care.
And there were questions at her resignation news conference about a police inquiry into the SNP’s finances.
But perhaps we have been too quick to forget the impact of Covid.
During the pandemic the first minister was widely praised for the calmness and consistency of her public messaging, in contrast, said many of her supporters, with the behaviour of UK prime minister Boris Johnson.
There has been much debate about the impact our leaders had on society during that public health emergency but understandably much less discussion about the impact it had on our leaders.
Maybe the pandemic took a greater toll on Ms Sturgeon than was apparent at the time. She certainly mentions it often, and did so again in her resignation speech.
And then, of course, there is gender, the issue that has dominated politics in Scotland this year.
The first minister was adamant that removing medical, legal and administrative hurdles to make it easier for someone to change sex on their birth certificate was morally the right thing to do.
But her dismissal of critics who said this would endanger women in female-only spaces enraged not just some of her opponents but also some members of her own party, including some in her government.
The Gender Recognition Reform bill, supported by Labour, was approved by Holyrood by a big majority but blocked by Downing Street from becoming law.
Then came an outcry about the initial decision to send a convicted double rapist, Isla Bryson, to Cornton Vale women’s prison near Stirling.
Ms Sturgeon stumbled in her response, struggling to articulate whether she believed Bryson was genuinely transgender or was simply claiming to be a woman to ensure an easier time in jail.
The outgoing first minister insists gender was not the underlying, or even the proximate, cause of her resignation.
Even so, it is a headache for her successor. The SNP leader had promised to seek a judicial review of the unprecedented decision by the UK government to use Section 35 of the Scotland Act, which established devolution, to block the bill from receiving royal assent.
Now a new SNP leader will have to decide whether to continue or abandon that fight.
He or she may also have to re-examine and possibly even refresh both the strategic vision for Scottish independence and the practical tactics needed to deliver it.
Ms Sturgeon will go down in history as a politician who kept the flame of independence burning after it was rejected at the ballot box.
How she is judged by history will depend on whether her tenure was a waypoint on the road to a new Scottish state or a diversion leading to a constitutional dead end.