MAE SAI, Thailand — As the world watched rescuers struggle to save 12 boys and their soccer coach trapped in a cave in northern Thailand, the tech billionaire Elon Musk dreamed up a “kid-size” submarine to help. It turns out they didn’t need it.

So he left it there, “in case it may be useful in the future,” he said on Twitter.

By Tuesday, the rescue operation had succeeded in saving all 13 people trapped in the Tham Luang Cave. Earlier this week, eight of the soccer teammates were evacuated from the flooded cave, a mission that required guiding the boys through passageways filled with water.

[Update: The Thai Navy may have a use for the abandoned mini-submarine.]

It was a daunting task. On Friday, a former Thai Navy SEAL lost consciousness and died while placing air canisters on a route within the cave being used in the rescue effort.

Once the last four boys, their soccer coach and military personnel were evacuated Tuesday, Thai officials said in a Facebook post that the mission was complete. It had taken 18 days, dozens of divers and hundreds of volunteers, but Mr. Musk’s mini-submarine invention was left on the sidelines, a Thai official said.