LOS ANGELES — A British cave explorer who helped rescue a dozen boys and their soccer coach from a flooded Thailand cave last year testified Wednesday that Elon Musk branded him a pedophile and sullied his reputation.

Vernon Unsworth choked up as he described the effect of the “pedo guy” tweet the Tesla CEO fired off in anger after Unsworth belittled the sub Musk built for the rescue that was never used.

“I was effectively given a life sentence with no parole,” Unsworth said. “It feels very raw, I feel humiliated, ashamed, dirtied.”

Unsworth said he had to sue Musk for defamation because if he didn’t the allegation would seem true.

Unsworth is seeking unspecified damages for pain, suffering and emotional distress from the tech entrepreneur who testified that his stock in Tesla and SpaceX is worth around $20 billion.

Musk insisted earlier in the day that he never called Unsworth a pedophile, telling a Los Angeles federal jury that the phrase he tweeted off-the-cuff “was obviously a flippant insult, and no one interpreted it to mean pedophile.”

Unsworth’s lawyer asked the billionaire how the insult was cast in the media worldwide, and Musk said he recalled that news organizations “correctly interpreted it as an insult, not an accusation of pedophilia.”

That wasn’t the interpretation of Unsworth’s lawyer, however, who unsuccessfully tried to introduce headlines compiled by someone at one of Musk’s companies that showed many news outlets perceived the phrase to mean pedophile.

Judge Stephen Wilson said it would be up to jurors to apply the standard of what a reasonable person would think Musk meant, not what journalists think.

“These reporters are taking the word ‘pedo guy’ and writing their story saying it’s pedophilia,” Wilson said. “That makes a more interesting story than ’pedo guy.‴

Musk said he deleted the tweet within hours and apologized on Twitter two days later.

Musk said the insult meant only “creepy old man.”

The spat began when Unsworth ridiculed Musk’s effort to help in the rescue by having engineers at his companies, including Space X and The Boring Co., develop a mini-submarine that could transport the boys. Despite working around the clock to build the sub, Musk arrived in Thailand late in the rescue effort and the craft was never used.

Unsworth called it nothing more than a “PR stunt” and said Musk could stick the sub “where it hurts.”

On cross-examination, Unsworth said his jab at Musk was just an idiomatic expression and not meant to be taken literally. That appeared to score a point for the defense because Musk said the same thing about his tweet.