In a tough SNP leadership contest, Humza Yousaf endured scathing criticism and repeated demands to resign over his management of the NHS as health secretary.
Far from stepping down he has now been propelled into the top job after Nicola Sturgeon’s resignation paved the way for him to take over.
Moments after securing victory on Monday, Mr Yousaf promised to unite his party. But he only won by a narrow margin and has offered little new on independence.
Here’s how the SNP’s new leader went from being branded one of his party’s worst ministers to the man who will lead Scotland.
Straight out the blocks
In the days following Ms Sturgeon’s shock decision to quit, there was uncertainty over who would step forward.
Deputy First Minister John Swinney ruled himself out the following day, eliminating one possible major contender.
A confident Mr Yousaf became the first senior government figure to put his hat in the ring three days later.
He pitched himself as the continuity candidate who was best placed to carry forward Ms Sturgeon’s legacy.
The Glasgow Pollok MSP was still far from the favourite at this stage and the SNP’s unionist opponents in Holyrood mocked his credentials.
But as former Westminster chief Angus Robertson declined to stand and Mr Yousaf launched his campaign, events elsewhere soon made him the overwhelming frontrunner.
Campaign meltdown
Finance Secretary and Highland MSP Kate Forbes had been tipped to replace Ms Sturgeon and was immediately among the leading contenders to replace her.
Announcing her intention to stand, it appeared as if she would be the strongest barrier standing between Mr Yousaf and the top job.
But longstanding questions surrounding the influence of her faith on policy decisions plunged her bid to become first minister into chaos.
Ms Forbes admitted she would have voted against gay marriage had she been an MSP at the time, and claimed it was wrong to have children outside wedlock.
Backers, such as ministers Richard Lochhead and Tom Arthur, deserted her campaign.
And just as support for Ms Forbes was ebbing away, Mr Yousaf got some major endorsements.
Party choice
Westminster leader and Aberdeen MP Stephen Flynn gave Mr Yousaf’s hopes a boost when he revealed he was voting for him.
Not long afterwards, Mr Swinney added his name to the list.
Mr Flynn’s House of Commons deputy, Mhairi Black, and his predecessor, Ian Blackford, also favoured Mr Yousaf.
“I think he had a lot going for him,” says Edinburgh University politics expert James Mitchell. “The backing was phenomenal for him.”
It became clear he was the preferred choice for much of his party – but were the SNP membership going to simply fall in line?
LISTEN: Humza Yousaf on family, racism and the NHS
SNP divide
Despite an early advantage, Mr Yousaf discovered his pathway to power would not be an easy ride as Ms Forbes came out fighting.
During an explosive TV debate, the Skye, Lochaber and Badenoch MSP claimed he had presided over record A&E waiting times and failed in all his major government jobs.
Polling indicated Ms Forbes was much more popular than her leadership rival among the wider public, indicating the contest was far from done.
Mr Yousaf’s promise of continuity appeared stale to some SNP members frustrated with a lack of progress on securing independence.
Prof Mitchell says the new party leader was forced to change tack to reinvigorate his campaign and cross the finishing line.
The academic adds: “He did manage to distance himself from what he was doing at the start of the campaign.
“He scraped that victory by having to change his position rather than being seen simply as Nicola Sturgeon mark two. He knew he was in trouble.
“He clearly listened and heard criticisms of the Sturgeon years. He responded, but he did it in a way that didn’t dismiss Sturgeon.”
What happens next?
Mr Yousaf secured victory as expected, but failed to win the backing of a majority of SNP members at the first time of asking.
Just over 48% of those voting said he was their preferred choice. He then got 52% in the final-run off against main rival Ms Forbes.
In office, Mr Yousaf will face the tough task of proving his critics wrong as he tries to prove he can deliver independence.
He plans to challenge the UK Government’s decision to block new SNP laws aimed at making self-identification easier for transgender people.
Improving the NHS as he steps away from his role as health secretary will also be high on his agenda.
Yet major doubts will linger over whether Mr Yousaf is truly capable of following on from his predecessor.
Can a man who fell out with his nearest rival, and failed to win a clear majority of the vote in the first round command the respect of the country?
Conversation