Scotland’s former first minister has accused Elon Musk of accessing his private messages as part of a campaign to “besmirch” his reputation.

Humza Yousaf claimed Mr Musk, one of the richest men in the world, “scours” the confidential communications of people he sees as a threat.

The former SNP leader also said he has “no doubt” the billionaire owner of social media site X is racist.

The two men have been involved in an ongoing feud since Mr Yousaf was first minister.

Elon Musk has just been appointed to jointly head a new US government department being created by President-election Donald Trump (Leon Neal/PA)

During unrest in parts of England and Northern Ireland this summer, Mr Yousaf referred to Mr Musk as a “race baiter” and claimed he was “one of the most dangerous men on the planet”.

The Tesla owner – who has been appointed by US President-elect Donald Trump to head a government department to cut regulation – replied by claiming Mr Yousaf is “obviously super racist against white people”.

Mr Musk said: “I dare that scumbag to sue me. Go ahead, make my day.”

He then added: “Legal discovery will show that however big a racist he’s been in public communications, he is vastly worse in private communications.”

The former first minister said the businessman’s comments were an attempt to “threaten and intimidate” him.

Asked if he thinks Mr Musk had access to his X messages, Mr Yousaf told the Tortoise Media’s Elon’s Spies podcast: “I’m certain he absolutely does and I’m certain he scours the private messages of those that he sees as a threat.

“In fact, I’m certain he has a whole team of people who are now looking at any information they can gather on me and try to use it to besmirch my reputation, and he’ll use any nefarious tactics in order to do that.”

The podcast said it understood Mr Musk had denied accessing private messages on X.

The former first minister, who is now a backbench MSP at Holyrood, said he will continue to speak out.

“Let me be clear that Elon Musk could have trillions, let alone billions, and he wouldn’t be able to shut me up,” he said.

“We’re going to continue to call out his racist, far-right white supremacist tendencies.

“But that caught me by surprise and I started to wonder what it was he was possibly talking about.

“I thought well okay, this is somebody who obviously has access to Twitter DMs (direct messages) or X DMs, and that should ring alarm bells for people.

“Your private conversations you have in your DMs, how secure are they?”

Humza Yousaf and Elon Musk have had several spats on X (Yui Mok/PA)

Mr Yousaf claimed Mr Musk was making a “pointed accusation” and added that his followers had encouraged him to publicly release the messages.

He said: “I’m thinking, I’ve been on Twitter for a long time, have I made an off-colour joke? Have I said something in a private communication?

“So, I thought I better do the belt and braces thing, and as I say there was nothing there, and unsurprisingly so.

“But here is somebody who is basically saying to me by the way ‘you better watch out. I’m going to release stuff on you and it’s going to make your life hell’.”

Mr Yousaf repeated his previous remarks that the billionaire is “one of the most dangerous men on the planet”.

He added: “He’s unaccountable, one of the wealthiest, by some accounts, the wealthiest man, an individual on the planet.

“He does what he wants, says what he wants and does not care about the consequences.”

X has been approached for comment.