Tesla founder Elon Musk has appeared in court in California to answer a lawsuit brought by a British cave diver he called "pedo guy" on Twitter.
Vernon Unsworth, who helped rescue 12 boys trapped in a Thai cave last year, is suing for defamation.
Mr Musk, the first to testify at the Los Angeles court, said Mr Unsworth had insulted him, so he insulted him back.
Mr Unsworth's legal team have described Mr Musk's tweet as "vile and false" and are seeking punitive damages.
The Tesla and SpaceX billionaire posted the tweet, since deleted, after Mr Unsworth publicly rejected his proposal to use a mini-submarine to rescue the boys - members of a football team who became trapped deep inside a cave in northern Thailand last June.
In a TV interview at the time, Mr Unsworth dismissed the idea as a PR stunt and suggested the American "stick his submarine where it hurts".
This prompted a series of tweets from Mr Musk, including one describing Mr Unsworth as a "pedo guy".
In his court testimony, Mr Musk said Mr Vernon's comments to CNN were "wrong and insulting, and so I insulted him back."
They were "an unprovoked attack on what was a good-natured attempt to help the kids".
Mr Musk told the court he had thought Mr Unsworth "was just some random creepy guy" and "unrelated to the rescue".
The Tesla boss later apologised for the tweet after stocks in his Tesla car company fell 4%.
In a filing as part of a failed request to have the case thrown out of court he suggested that in South Africa, where he grew up, the term "pedo guy" is a common insult meaning "creepy old man" and does not accuse someone of paedophilia. Mr Unsworth's legal team say this is "offensive to the truth".
The judge has denied the defence's request to define Mr Unsworth as a "public figure" - meaning lawyers for Mr Unsworth do not have to prove Mr Musk acted with "actual malice", lowering the bar necessary to win the case.
The case continues.