A Los Angeles judge has slapped down Elon Musk's bid to have a defamation case against him thrown out of court.

Musk called British hero Vernon Unsworth a 'pedo guy' and 'child rapist' on Twitter and in emails, after Unsworth helped rescue boys stuck in a Thai cave last year.

Unsworth is suing the Tesla mogul for defamation in California federal court.

Musk asked the judge to throw out the case last month, claiming his tweets were protected by the First Amendment and shouldn't have been taken seriously.

Elon Musk asked a California judge to throw out a lawsuit filed against him by a British diver who accused the tech entrepreneur of falsely calling him a pedophile but the judge refused

Musk labelled the British diver 'pedo guy' in a tweet before later deleting the message

Musk later apologized on Twitter, claiming his words were 'spoken in anger.' The tech boss is now asking to have the lawsuit dismissed

Mr Musk (right) had accused Mr Unsworth (left) of being ‘a paedo’ during the rescue of 12 schoolboys from the Tham Luang Nang Non cave complex last summer. The matter was then revived last week when Mr Musk suggested to BuzzFeed that Mr Unsworth was a 'child rapist'

However, in an order issued on Friday Judge Stephen Wilson denied Musk's request, allowing the case to go forward.

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.'

Unsworth, 63, is a British financial broker from St Albans, near London. He has a 40-year-old girlfriend of seven years, Woranan Ratrawiphukkun.

The experienced diver was part of a team who successfully rescued a soccer team of 12 boys and a coach who got trapped for 18 days in a Thai cave last July.

British diver Vern Unsworth played a leading role in the operation to rescue a group of boys trapped in a cave in Thailand. He got to meet Prime Minister Theresa May at Downing Street during a reception for those that helped with the Thai cave rescue operation

Musk called diver Vernon Unsworth (pictured) a 'pedo' in a tweet to his 22.5 million followers after Unsworth criticized Musk's efforts to help rescue young soccer players trapped in a cave

Woranan Ratrawiphukkun, 40 (left) has been in a relationship with British expat in Thailand (right) Vernon Unsworth for seven years

Unsworth was hailed as a hero and was invited to visit the British Prime Minister at her residence in Number 10 Downing Street.

In his lawsuit, filed in September, the Brit demanded at least $75,000 in compensatory damages plus unspecified punitive damages from Musk.

On July 15 last year, the Telsa founder tweeted to his more than 22 million followers, calling Unsworth a 'pedo guy'.

Although later apologizing, Musk doubled-down on his comments in an email to a Buzzfeed journalist, telling the reporter to investigate Unsworth and 'stop defending child rapists'.

In their bid to get the case thrown out, Musk's lawyers characterized his slurs against Unsworth as 'over-the-top' comments in a 'schoolyard spat on social media'.

They wrote the tweets and emails were 'just imaginative attacks; even if offensive, such speculative insults are by their nature opinion and protected by the First Amendment.'

However, Judge Wilson was not persuaded, and denied Musk's request to dismiss the case.