The tech billionaire Elon Musk on Wednesday walked back his baseless claim that a British diver involved in the cave rescue efforts in Thailand was a pedophile, an accusation made after the man criticized a submarine that Mr. Musk had said he built to help with the rescue.

The cave diver, Vern Unsworth, who helped with the effort to rescue 12 boys and their soccer coach, had told CNN last week that the miniature submarine, built with rocket parts, was a “P.R. stunt” and that Mr. Musk could “stick his submarine where it hurts.”

That drew an angry response over the weekend from Mr. Musk, who called Mr. Unsworth a “pedo guy” in a series of angry tweets defending the vessel.

The posts by Mr. Musk, which were later deleted, reverberated beyond social media. The news spooked investors and contributed to a slide on Monday in the stock price of the electric car company Tesla, for which Mr. Musk serves as chief executive. Tesla stock climbed again on Tuesday.