Tesla co-founder Elon Musk said Tuesday he did not literally call a British caver a pedophile during their infamous spat on Twitter, telling a Los Angeles federal court that he had simply defended himself from unprovoked insults.

The tech billionaire told the defamation trial jury he had been "upset" when he described British diver Vernon Unsworth -- who helped rescue youth soccer players trapped in a cave in Thailand -- as "pedo guy" in a tweet.

During the July 2018 row, Unsworth had described the 48-year-old entrepreneur's proposal to build a mini-submarine to rescue the boys as a "PR stunt."

"It was an unprovoked attack on a good-natured attempt to rescue the kids," Musk, dressed in a black suit and dark tie, told the courtroom Tuesday. "I was upset."

"It was wrong and insulting and so I insulted him back," he said.

Musk was questioned by Unsworth's attorney Lin Wood about comments made by the caver, who had said the custom-built device would never have fit in the cave and suggested that Musk could "stick his submarine where it hurts."

British diver Vernon Unsworth arrives at US District Court in Los Angeles, California on December 3, 2019, with his attorney Lin Wood (R) for the defamation trial of Tesla co-founder and CEO Elon Musk
British diver Vernon Unsworth arrives at US District Court in Los Angeles, California on December 3, 2019, with his attorney Lin Wood (R) for the defamation trial of Tesla co-founder and CEO Elon Musk AFP / Frederic J. BROWN

"It's idiomatic, just as I was not literally meaning he was a pedophile," replied Musk.

Asked why he failed to specifically say that Unsworth was not a pedophile in his apology, Musk said it seemed obvious to him that this was his intent.

"For me, that did not require any clarification ... (which) would have been worse," he said.

"I apologized and I say again 'I apologize Mr. Unsworth'," he added, as the British caver looked on across the courtroom, visibly uncomfortable under the media spotlight.

Musk's testimony was to continue on Wednesday.

His attorney Alex Spiro earlier Tuesday told the jury of six women and two men that his client meant no harm when he hit out at Unsworth and that his words were spoken in anger.

"The tweets are not allegations of crimes. They are joking, taunting tweets in a fight between two men," Spiro told the court.

Elon Musk leaves court in Los Angeles during a defamation trial over him calling a British rescue diver 'Pedo Guy'
Elon Musk leaves court in Los Angeles during a defamation trial over him calling a British rescue diver 'Pedo Guy' GETTY IMAGES NORTH AMERICA / Apu Gomes

He also repeated his clients' claim that "pedo guy" was a common insult in South Africa, where Musk grew up.

"Pedo guy (means) creepy old guy" in South Africa, Spiro said.

Unsworth's attorneys have challenged Musk's defense, presenting as evidence another tweet he wrote in response to a question about whether he thought the British caver was a pedophile.

"Bet ya a signed dollar it's true," Musk tweeted at the time.

The Tesla and SpaceX CEO also said in court filings that following his spat with Unsworth, one of his aides had hired a private investigator to dig up dirt on the 64-year-old caver.

He also suggested in emails to the website BuzzFeed News that Unsworth was a "child rapist."

Wood has dismissed Musk's unsubstantiated claims as "disgusting" and an attempt to smear his client's reputation.

He said he looks forward to seeing "how a jury reacts to (Musk's) defense strategy" under oath.

Unsworth, who lives in Britain and Thailand, is expected to give his version of events when he testifies in the trial set to last through Friday.

He is seeking unspecified damages for pain, suffering and emotional distress.

Musk had sought to have the case dismissed but a judge in October rejected the request.

The judge also rejected a bid to classify Unsworth as a public figure, which would have made defamation harder to prove.