Carwyn Jones has announced he will stand down as Wales’ first minister in the autumn.
The AM for Bridgend made the announcement at the Welsh Labour party conference in Llandudno, which he said would be his last as leader.
Referring to the death of Carl Sargeant Mr Jones, 51, said he had been through the “darkest of times”.
Mr Sargeant was found dead in November, days after Mr Jones sacked him from his cabinet job.
The communities secretary was dismissed after allegations emerged about his personal conduct, prompting a Welsh Labour investigation.
UK Labour leader Jeremy Corbyn paid tribute to the first minister’s “tireless commitment to making Wales a more equal country”.
Mr Jones, who has been first minister and Welsh Labour leader since 2009, said his exit would give his family, his party and the country a “fresh start”.
The man widely considered to be a potential front-runner contender in the leadership race, Finance Secretary Mark Drakeford, says he is giving the matter “serious consideration”.
Referring to his wife and family, the first minister told party delegates: “I don’t think anyone can know what the last few months have been like – no one apart from Lisa and the kids.
“They have carried me through the darkest of times. I have asked too much of them at times. It’s time for me to think about what’s fair to them.”
The conference reacted in shock when Mr Jones said: “This will be the last Welsh Labour conference I address as party leader.
“I intend to stand down as your leader in the autumn allowing for a new first minister to take their place by the end of this year.
“By that point it will make sense to have a fresh start for my family, my party and my country.”
The announcement came despite the Welsh Labour leader telling BBC Wales on Friday that he was looking forward to continuing as first minister “for some time to come”.
Mr Jones has been under pressure from Mr Sargeant’s family and both opposition and Labour politicians who have wanted answers to questions over the circumstances of the minister’s sacking.
Carl Sargeant’s death led to Mr Jones announcing several inquiries. Two have been completed, but an independent probe into the circumstances led by QC Paul Bowen around his sacking is yet to begin.
Following Mr Jones’ announcement, Carl Sargeant’s son Jack, who has taken the Alyn and Deeside seat vacated by his father, said: “Nothing changes. The inquiries are still relevant and should continue.”
On Friday the lawyer for Jack Sargeant said Mr Jones’ manner had caused the family distress.
Mr Jones has said he did not see how that could be the case.
Mark Drakeford, who has been tipped as a future leader of the party, did not rule out the prospect of running for Welsh Labour leader when he told BBC Wales: “I will talk to others. I’ve got to think of my own family in talking to them, and I will think about it very seriously.
“But I can quite easily see why that serious consideration would conclude that I wouldn’t want to do it.”
Jeremy Miles, the Welsh Government’s counsel general, also did not rule out the prospect of running when BBC Wales asked if he would stand, saying it would depend “who puts their name forward”.
Huw Irranca-Davies, minister for children and social care, said he was also considering running.
Alun Davies, the local government secretary, said he would wait and see what to do.
But he insisted that the next leader must not be elected under the current electoral college system, which was used to elect deputy leader Carolyn Harris whose victory was also announced on Saturday.
Leadership elections have been a controversial matter in the Labour party, with many grassroots campaigners calling for one member one vote (OMOV).
Andrew RT Davies, Welsh Conservative leader, said: “Whilst we have spent many years on opposite sides of the political divide, you have to recognise Carwyn’s significant contribution to public life in Wales, and the huge achievement of serving his country at the highest level for so long.”
Plaid Cymru leader, Leanne Wood, congratulated Carwyn Jones on his nine years as first minister, but added: “Wales needs more than a change of leader. We need a new government with the ideas, the values and the drive to build our nation into the successful country we know it could be.”
Former Labour AM and ex-local government minister Leighton Andrews, who has been critical of the first minister following Carl Sargeant’s death, said Mr Jones had many significant achievements during his period as first minister, but said unanswered questions remain.
But he said: “These last five plus months have been very difficult and there are still unanswered questions which the Bowen inquiry will investigate.”
Health secretary Vaughan Gething told BBC Wales that the announcement was a “shock”, but denied Mr Jones was leaving “under a cloud”.
He also did not rule himself out of a future race, saying Saturday “was not the day to be running out of the starting blocks”.
The Conservative Welsh Secretary Alun Cairns said: “My relationship with the first minister has always been positive, pragmatic and driven by a mutual desire to get the best outcome for the Welsh people.”
First Minister of Scotland Nicola Sturgeon said she had enjoyed working with the first minister – the two have jointly campaigned against provisions for devolution in the Brexit bill.
Analysis by BBC Welsh affairs editor Vaughan Roderick
It’s a sad end to a political career.
Carwyn Jones would have wanted, in different circumstances, to continue for longer.
We should take what he says about the pressure on his family entirely at face value, I’m certain of what he is saying here is correct.
History will be kind to Carwyn Jones. He has had to manage Wales through a period of austerity and has managed to keep Labour in power. He has a lot of things going for him.
But at this moment, its the cloud of that reshuffle that went wrong and the results that came from it that will be on most people’s minds.