Tech billionaire Elon Musk will have to face a lawsuit for defamation for calling a British cave diver a “pedo guy” on Twitter.

Musk also called Vernon Unsworth, who played an instrumental role in the rescue of a group of Thai boys trapped in the Tham Luang cave last year, a “child rapist” in an email to a journalist.

The war of words erupted after Unsworth mocked a mini-submarine that Musk had built and had sent to the cave to help with the rescue mission.

Unsworth said the submarine was nothing more than a “p.r. stunt” and that Musk could “stick his submarine where it hurts”.

Musk went on to call Unsworth “a pedo guy” on Twitter. The post was later deleted and he apologised.

Musk had tried to get the lawsuit thrown out of court in California with his legal team citing freedom of speech laws, adding that his comments were “over the top” and part of a “schoolyard spat on social media”.

However, on Friday, a judge in Los Angeles dismissed the plea and ruled that the defamation case would go ahead.

Lin Wood, one of Unsworth’s lawyers, told DailyMail.com: “We are extremely pleased with the denial and I look forward to speaking with Musk under oath about his false, heinous accusations against Mr Unsworth.”