Humza Yousaf has won the vote to take over from Nicola Sturgeon as SNP leader and become Scotland’s new first minister.
The Dundee-based MSP was able to narrowly beat main rival Kate Forbes and outsider candidate Ash Regan as the contest went down to the wire.
Mr Yousaf secured 52% of the final vote in the run-off against Ms Forbes, after initially being backed by 48% of the party’s members.
He will be confirmed as first minister later this week, becoming the first leader of the Scottish Government from an ethnic minority background.
Mr Yousaf said: “It is hard for me to find the words to describe just how honoured I am to be entrusted by our membership of the SNP to be the party’s next leader.”
He paid tribute to the two candidates who ran against him in the leadership contest and signalled his intent to heal wounds within his party.
The new SNP leader added: “I feel like the luckiest man in the world.”
The outgoing health secretary has been a close ally of Ms Sturgeon and pitched himself as the continuity candidate who can carry forward her legacy.
He first entered Holyrood in 2011. Before managing the NHS, he served as justice secretary and transport minister.
Aged 37, Mr Yousaf will become the youngest of Scotland’s six first ministers once he is sworn into the top job.
The new SNP leader became an early frontrunner to replace Ms Sturgeon after Ms Forbes admitted she would have voted against gay marriage.
Mr Yousaf’s campaign was given a further boost when he secured the backing of key party figures such as Perthshire’s John Swinney and Dundee-born Westminster chief Stephen Flynn.
However, he came in for criticism from Ms Forbes over his performance in government during an explosive televised debate which exposed major rifts in the SNP.
Tory and Labour rivals branded Mr Yousaf unfit to become first minister and he will face a huge task proving he is up to the top post.
Despite their disagreements, Ms Forbes congratulated the new SNP chief on his huge success.
She said: “Whatever the robust disagreements or frank exchanges of the last few weeks, I am confident we will unite behind Humza as our new party leader.”
Just over 50,000 of the SNP’s members in total voted in the leadership contest.
To officially enter Bute House, Mr Yousaf now needs to be voted in by MSPs in Holyrood.
But given his party is only just short of a majority and shares power with the Scottish Greens, that is expected to be a formality.