Elon Musk has apologised to the British diver he branded a ‘pedo’ in a Twitter tirade after he rejected the tech billionaire’s submarine idea pitched during the Thailand cave rescue.

Mr Musk launched an attack on Vern Unsworth, 63, who played a key role in the rescue of the 12 boys and their coach, in a since deleted tweet.

Taking to Twitter once again, Mr Musk said: “as this well-written article suggests, my words were spoken in anger after Mr Unsworth said several untruths and suggested I engage in a sexual act with the mini-sub, which had been built as an act of kindness and according to specifications from the dive team leader”.

Mr Musk was referencing a thread on question-and-answer site Quora which attempted to explain Musk’s involvement in the Thailand cave rescue.

Mr Musk continued, tweeting: “Nonetheless, his actions against me do not justify my actions against him, and for that I apologise to Mr Unsworth and to the companies I represent as leader. The fault is mine and mine alone.

Mr Unsworth had said he was considering legal action over Musk’s comments, telling 9News “I’ll hopefully get a copy of the Tweet. It’s not over”.

He also said the Tesla founder can "stick his submarine where it hurts" and it had absolutely no chance of working.

“It was just a PR stunt," Mr Unsworth said.

While the rest of the world was celebrating the successful rescue, Musk's offensive comments have cast a shadow over Mr Unsworth.

“There is no justification. At the end of the day we were here to rescue these young boys,” he said.

He also said the submarine wouldn’t have been able to navigate the complex tunnels of the Tham Luang cave complex, adding Mr Musk was not needed and was asked to leave.

Mr Musk didn’t take the criticism lying down and launched a furious attack on the experienced diver after responding to a piece in the New York Times which called his effort "commendable".

Dr Zeynep Tufekci, a tech expert, wrote how Mr Musk became frustrated when rescue crews said his contraption was impractical for the task at hand.

"Mr Musk’s desire to help was commendable," she wrote.

"But when the head of the rescue operation, Narongsak Osottanakorn, declared that Mr Musk’s contraption was impractical for the task at hand — a task that had been completed, at that point, by some of the world’s top cave divers — Mr Musk responded with irritation," she wrote.

Mr Musk then responded to Dr Zeyenp's peice and tweeted: "Never saw this British expat guy who lives in Thailand (sus) at any point when we were in the caves

“Only people in sight were the Thai navy/army guys, who were great. Thai navy seals escorted us in — total opposite of wanting us to leave.”