Of all the controversies stirred up by Tesla CEO Elon Musk last year, none was more embarrassing than when he called expert spelunker and diver Vernon Unsworth a "pedo guy" and "child rapist," after Unsworth criticized him for getting involved in a massive effort to rescue 12 boys and their soccer coach from a flooded cave in Thailand.

Musk now faces a defamation lawsuit in the U.S. from Unsworth, who, in a lengthy filing released late Monday, illustrates just how far the CEO is willing to go when he digs in on an issue, even something so far afield from his businesses, Tesla, SpaceX, the Boring Company and Neuralink.

The dispute began in July 2018, after Musk said that his team was developing a mini-submarine — a pod — that could assist in carrying the kids and their coach to safety. Unsworth said in a TV interview at the time that it wouldn't help, which led to Musk's multiple online rants.

What Unsworth now reveals, through deposition transcripts and emails that his lawyers obtained, is that Musk and his affiliates paid private investigators, including one who turned out to be a convicted felon, to try and dig up dirt on the cave rescuer. Additionally, Musk directed his team to pressure foreign officials in Thailand to say nice things about him and his mini-sub, even as they were grappling with what would prove to be a deadly rescue mission.

Last month, Musk asked the court to decide that Unsworth had no viable reason for the defamation case, in part, because he claims he was using slang and didn't really mean Unsworth was a pedophile. Unsworth's legal team, led by L. Lin Wood, says the case should proceed because, among other reasons, Musk made several contradictory and false statements to defend himself under oath.

"Musk's motion is based principally on the antithetical bases that, on the one hand, he was not calling Unsworth a pedophile, while on the other hand, he did not harbor serious doubts as to whether Unsworth was actually a pedophile," Unsworth's attorneys wrote in the filing. "Musk's accusations are false, defamatory, and were published negligently and with actual malice. His motion for summary judgment must be denied."

Musk's attorney, Alex Spiro, said in a statement e-mailed by a PR firm to CNBC: "This case is nothing but a money-grab in which Unsworth has hired an agent and pursued profit, publicity and self-promotion at every turn. The truth of his motivations and actions will come out soon enough."

Wood replied, on Twitter, "Musk lawyer's comments are simply more accusations of a dishonest Elon Musk defense & PR campaign to demean & falsely attack my client. Since the rescue, Mr. Unsworth has received a total of £2,400 for his assistance in connection with two documentaries about Thai Cave Rescue."

tweet L Lin Wood

As Musk struggles to stabilize his electric vehicle maker's precarious financial position, the lawsuit is yet another distraction for the CEO and Tesla shareholders. Tesla's stock is down 28% this year, as the company suffers from ongoing legal and logistical challenges, and attempts to sell cars in more markets than ever before.

The Unsworth case looks particularly bad for Musk, whose image has taken a beating amid conflicts with employees, investors and regulators in the past two years. It also shows a shocking lapse in judgment.