Nicola Sturgeon has resigned as Scotland’s first minister after more than eight years in the job.
The Scottish National Party leader said she will step down after her successor is elected.
Sturgeon made the announcement at a press conference in Edinburgh on Wednesday morning saying she had been “wrestling” with the question for some weeks.
“Part of serving well would be to know, almost instinctively, when the time is right to make way for someone else,” Sturgeon said.
“In my head and in my heart I know that time is now. That it is right for me, for my party and for the country.”
Sturgeon has been first minister since November 2014, when she took over from Alex Salmond following the independence referendum.
She has been the country’s longest-serving first minister.
The news came as a surprise after Sturgeon insisted just three weeks ago she was “nowhere near” ready to quit as Scotland’s first minister.
Sturgeon also told the BBC last month she would “like to think” she would be the leader to take Scotland out of the UK.
However, BBC chief political correspondent Nick Eardley reported a source close to her saying: “She’s had enough.”
Sturgeon has recently been embroiled in a row over her government’s attempt to make it easier for people to legally change gender.
The plans have now been blocked by Westminster but triggered a leadership crisis.
Internal dissent, almost unheard of in the SNP, broke out over Sturgeon’s handling of the affair.
Voters also started to make clear their dissatisfaction after a YouGov poll showed Sturgeon’s approval ratings had plummeted to negative territory.
However, during her speech Sturgeon said her decision to resign was “not a reaction to short-term pressures”.
“This decision comes from a deeper and longer-term assessment,” she said.
Pressed on the row surrounding transgender prisoners, Sturgeon insisted: “No, that issue wasn’t the final straw”.
Sturgeon also confirmed she was “not leaving politics”, adding that she will continue to fight for Scottish independence.
Alison Thewliss, the SNP MP for Glasgow Central and the party’s home affairs spokesperson, said she was “gutted”.
She tweeted: “Absolutely gutted about this. Nicola has been an incredible leader.”
SNP MP Stewart McDonald described Sturgeon as “the finest public servant of the devolution age”.
“Nicola Sturgeon is the finest public servant of the devolution age,” the MP for Glasgow South tweeted.
“Her public service, personal resilience and commitment to Scotland is unmatched, and she has served our party unlike anyone else. She will be an enormous loss as first minister and SNP leader. Thank you!”