Kezia Dugdale has resigned as leader of Scottish Labour.
Ms Dugdale said she wanted to give the “space and time” to prepare for the next Scottish Parliament election in 2021.
But she denied suggestions she was leaving now to prevent being being pushed.
In an interview with BBC Scotland she said she had taken over the leadership when the party was “on its knees” in Scotland.
In a statement she said: “As chair of the party, I am writing to you today to resign as leader of the Scottish Labour Party.
“It has been an honour and a privilege to have served this party in a leadership position for the last two and a half years, covering four national elections and one referendum.
“I have worked with many great people, not least the staff in our HQ led by Brian Roy and those in the Scottish Parliament, whose boundless energy, expertise and good humour has guided our party through some dark hours and difficult times.
“I’d like to thank my shadow cabinet for their efforts, and in particular Iain Gray for his unflinching love and support and James Kelly for the thankless but crucial job he does so well as our business manager.
Earlier this year I lost a dear friend who taught me a lot about how to live. His terminal illness forced him to identify what he really wanted from life, how to make the most of it and how to make a difference. He taught me how precious and short life was and never to waste a moment.
Being leader has always been a difficult but fulfilling challenge. One that until now I have enjoyed, driven by a clear guiding purpose and goals, many of which I have achieved.”
Ms Dugdale, who is leaving with immediate effect, said she had devoted “every waking moment of my life” to improving Labour’s fortunes in Scotland,
She added: “I have thought long and hard about this. I care deeply about the Labour Party – I love it and I have devoted my adult life to serving it in a number of different capacities.
“And I have just come to the conclusion that the best thing for it, the Labour Party, this precious, precious thing that has done so much good in our country, and indeed for me, is to pass that baton on.”
First Minister Nicola Sturgeon wished Ms Dugdale well for the future, writing on Twitter: “We may be opponents, but @kezdugdale led her party with guts and determination and I admired her for that.
“I wish her well for the future.”
Former Labour leader Ed Miliband thanked Ms Dugdale for her work, and said she gave her “heart and soul to leading Scottish Labour”.
He tweeted: “Thank You. You deserve to get your life back. Enjoy.”
Senior Labour MP David Lammy also paid tribute on Twitter, writing: “Thank you @kezdugdale for your years of tireless work, commitment to our movement and dedication to rebuilding our movement in Scotland.”
Ashfield MP Gloria De Piero tweeted that she was “sad” to hear Ms Dugdale was stepping down, and wrote that she was “always impressive” and “full of passion”.
She added: “And let’s face it Labour is not overrun with women leaders.”
Labour’s Stella Creasy tweeted: “Our @kezdugdale is diamond in the labour movement- brilliant, shining and lighting life in equal measure. Proud to know her and of her work.”
Labour leader Jeremy Corbyn said: “I’d like to thank Kezia Dugdale for her work as Scottish Labour leader and the important role she has played in rebuilding the party in Scotland.
“Kezia became Scottish leader at one of the most difficult times in the history of the Scottish Labour Party, and the party’s revival is now fully under way, with six new MPs and many more to come.
“I want to thank Kez for her tireless service to our party and movement, and look forward to campaigning with her in future for a country that works for the many not the few.”
Scottish Secretary David Mundell said: “Today as always @kezdugdale has shown she is a person of character and substance. I wish her well, but hope she stays in frontline politics.”
Ruth Davidson, Scottish Conservative leader, wrote: “Leadership can be tough and @kezdugdale deserves the thanks of her party for putting in the hard yards. I wish her well.”
During Ms Dugdale’s time in charge Labour has become the third party in Scotland, with Ruth Davidson’s Scottish Conservatives now having more MSPs and more MPs.
Ms Davidson said on Twitter: ” ‘Leadership can be tough and @kezdugdale deserves the thanks of her party for putting in the hard yards. I wish her well.”
Meanwhile Scottish Secretary David Mundell said: ”Today as always @kezdugdale has shown she is a person of character and substance. I wish her well, but hope she stays in frontline politics.”
Patrick Harvie, the co-convener of the Scottish Greens, said Ms Dugdale had ” served her party with dedication”.
He added: “Her decision to stand down can’t have been easy. I’d like to wish her well for the future.”
Scottish Liberal Democrat leader Willie Rennie said: ” Kezia Dugdale has been a good thing for Labour. Her open, friendly, and upbeat style was appealing. I enjoyed working with her on common causes and hope that will continue. I wish her well for the future.”