Tesla Inc. Chief Executive Elon Musk has apologized for lashing out at the British cave explorer who dismissed his efforts to help rescue the youth soccer team trapped in a Thai cave.

“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 leader,” Mr. Musk said in a post on his official Twitter account at 11:41 p.m. Tuesday in California, referring to cave explorer Vern Unsworth. “The fault is mine and mine alone.”

Mr....