Elon Musk has insisted his was an "off the cuff" insult hurriedly written in anger and not meant to be taken literally.
The chief executive of electric carmaker Tesla Inc and founder of rocket company SpaceX also acknowledged in a packed Los Angeles federal courtroom his net worth, mostly from stock holdings in those two companies, was about $US20 billion.
"Sometimes people think I have a lot of cash. I actually don't," he said.
Mr Musk, 48, the first witness to testify at his trial, also apologised again from the stand to the plaintiff, Vernon Unsworth, the British cave explorer and diver who is seeking unspecified compensatory and punitive damages in the case.
After leading a successful rescue of 12 boys and their soccer coach from a flooded cave in Thailand in July 2018, Mr Unsworth in a CNN interview mocked Mr Musk's offer of a mini-submersible as a public relations stunt, and said Mr Musk could "stick his submarine where it hurts".Mr Musk testified he took to Twitter two days later to lash back at Mr Unsworth because he found the comments "extremely rude and contemptuous".
A screenshot of Mr Musk's tweet, which has been deleted. Source: Twitter
"This was very much an off-the-cuff response," Mr Musk said.
Asked whether he was accusing Mr Unsworth of the crime of pedophilia by referring to him as "pedo guy" in a series of tweets, Mr Musk said: "Absolutely not."
"It's an insult, like saying mother-effer doesn't actually mean someone having sex with their mother," he said, using a sanitised version of a more vulgar expression.
Mr Musk's "pedo guy" tweet is one of three tweets that Mr Unsworth has said defamed him and harmed his reputation.
In one of the others, Mr Musk wrote: "Bet ya a signed dollar it's true," in response to a Twitter follower asking whether he was really suggesting that Unsworth was a pedophile.
On the witness stand on Wednesday, Mr Musk downplayed that tweet, saying: "It's obviously a low-stakes wager."US District Judge Stephen Wilson has said the case hinges on whether a reasonable person would take Mr Musk's tweets to mean that he was calling Mr Unsworth a pedophile.
Elon Musk sent a "tiny kid-sized submarine" to help rescue the Thai boys trapped in a cave. Source: AAP
To win the defamation case, Mr Unsworth needs to show that Mr Musk was negligent in publishing a falsehood that clearly identified him and caused him harm.
"Actual malice" by Mr Musk does not need to be proven because the judge deemed Mr Unsworth a private individual, not a public figure.
Although the case does not involve Tesla, Mr Musk's Twitter habits have long been under close scrutiny, with the company's investors and regulators expressing concerns about his tweets.
With 29.9 million followers, Mr Musk's social media account is a major source of publicity for the Palo Alto, California-based Tesla, which does not advertise.