Elon Musk has fallen on the sword after lashing out in anger ... calling one of the Thailand rescuers a pedo.

Musk says he made the comment in anger, after British diver Vern Unsworth said Musk was guilty of a "PR stunt" by bringing a mini-submarine to Thailand to rescue the soccer players and their coach. Unsworth said the sub would have been useless in the rescue effort.

That's when Musk went on Twitter and called him a "pedo."

Musk now says, "My words were spoken in anger after Mr. Unsworth said several untruths ... Nonetheless, his actions against me do not justify my actions against him, and for that I apologize to Mr. Unsworth and to the companies I represent as a leader. The fault is mine and mine alone."

Although Musk deleted the "pedo" tweet, Tesla stock fell 3% Monday, although it more than recovered Tuesday.  

Unsworth had threatened legal action. He hasn't responded to Musk's apology.