The result was announced during an event at Murrayfield Stadium in Edinburgh on Monday afternoon. It follows Nicola Sturgeon’s shock resignation in February.
The health secretary is expected to be declared Scotland’s sixth first minister after a vote in the Scottish Parliament on Tuesday.
The leadership needed to be decided by second preference votes after Mr Yousaf, the health secretary, received 24,336 votes in the initial round – 48.2 per cent of the total vote.
The Cabinet secretary finished with 26,032 votes – 52 per cent of the overall vote – once second preferences from eliminated third-placed candidate, former community safety minister Ash Regan, were redistributed.
Finance secretary Kate Forbes narrowly finished as runner-up in the race, receiving 23,890 votes (48 per cent) overall once second preferences were distributed.
Only 70 per cent of eligible SNP members chose to vote. The final number of eligible party voters was 72,169, but only 52,494 ballot papers containing valid votes were received.
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 and to be on the cusp of being our country’s next first minister.”
He paid tribute to Ms Forbes and Ms Regan, adding: “It’s felt we’ve seen each other more than our respective families. You both have put in an incredible shift and I know that collectively we will work hard as part of Team SNP.
He said it is now time for the SNP to come together and deliver independence.
"Leadership elections, by their very nature, can be bruising,” he said. “However, in the SNP we are a family. Over the last five weeks we may have been competitors or supporters of different candidates.
“We are no longer team Humza, or team Ash, or team Kate, we are one team. We will be the team, we will be the generation, that delivers independence for Scotland.”
Mr Yousaf added: “I feel like the luckiest man in the world to be standing here as leader of the SNP. A party I joined almost 20 years and that I love so dearly.”
Mr Yousaf paid tribute to the late Labour leader John Smith in his victory speech and said it was “the greatest honour and privilege of my life” to be the next first minister, should Parliament decide to elect him.
The reduced voting turnout brings to an end an acrimonious campaign that saw bad-tempered exchanges between the candidates in live television debates.
Peter Murrell, the SNP’s long-serving chief executive and Ms Sturgeon’s husband, was also forced to resign amid a row over membership numbers.
He quit with immediate effect after the party initially rubbished reports that its membership had dropped by 30,000, with the then-SNP head of communications Murray Foote dismissing the claims as “drivel”. In an embarrassing U-turn, however, the party then admitted that as of February 15 this year, its membership was at 72,186 – down from 103,884 in 2021.
Ms Regan received 5,599 first preference votes – well shy of both Mr Yousaf and Ms Forbes – leading to her early elimination.
Ms Forbes received 20,559 (40.7 per cent) of votes on first preference. The finance secretary received a greater share of the redistributed second preference votes, but it wasn’t enough to overcome her main rival’s tally.
Health secretary Humza Yousaf, finance secretary Kate Forbes and former community safety minister Ash Regan had each outlined very different visions for the future of the party and the country.
This was the first SNP leadership contest since 2004, and the new leader becomes only the party’s fifth since 1979.