Thai rescue teams arrange water pumping system at the entrance to a flooded cave complex where 12 boys and their soccer coach have been trapped since June 23, in Mae Sai, Chiang Rai province, northern Thailand. Credit: Royal Thai Navy | AP

As the last ambulances waited a muddy pathway flanked by lush fields, Thai navy officials confirmed Tuesday that every member of a youth soccer team — 12 boys and their 25-year-old coach — had been extracted from the flooded cave where they have been marooned for more than two weeks.

The jubilant news capped a dramatic search and treacherous three-day rescue mission that captivated the world.

“12 Wild Boars and coach out of the cave. Everyone safe,” the Thai Navy SEALs posted on their Facebook page, referring to the name of the soccer club.

The story of the boys and their novice monk-turned-soccer coach from this small town on the Thai-Myanmar border — remarkably found alive nine days after they went missing June 23 — launched an international rescue effort and intricate planning on how to maneuver all 13 safely through the narrow passageways and ink-black waters.

British, Australian, Chinese and Thai divers led them out, one tethered to each boy and one following from behind. An Australian doctor stationed in the cave has kept a lookout for days, and was among the last to be extracted.

International experts set up rescue communications, while Thai villagers flocked to a muddy rescue site to set up food stalls and massage stations.

The missions were also a race against the weather.

Rescuers had spent days balancing the risk of impending monsoons, which could have flooded the cave once again, and the team’s readiness to embark on the journey out, physically weakened by their ordeal.

The hint of setting sun and blue skies broke through the heavy clouds behind the caves as a helicopter whirred through the sky, carrying the last of the team south to a hospital in nearby Chiang Rai. Thai navy SEALs and a medic who had been stationed with the boys for days, preparing them for their dive, were brought out of the cave soon after.

On Sunday, officials decided they could no longer wait, as conditions were “as perfect as they will be.” Over the next three days, the boys were brought out in groups; four on the first day, four on the second and five on Tuesday.

The boys and the coach were found more than a week after they became stuck on a small, muddy patch deep in the cave’s network of chambers. The world has been rooting for them since, especially after warnings from experts about how much could go wrong in the process of bringing out the young boys, who cannot swim and were weakened by their long ordeal.

Their supporters have included world leaders, Facebook founder Mark Zuckerberg and billionaire inventor Elon Musk, who tasked his team of engineers to build a “kid-sized submarine” made out of rocket parts that will be able to move the young boys through the cave’s narrow passageways. On Monday night, Musk posted on Twitter that he had “just returned’ from the still-flooded cave, with photos of the rescue site where a team of swelling international experts have been working around the clock since the team was found.

“Leaving here in case it may be useful in the future,” he wrote, referring to the “mini-sub” which he has named after the team, the Wild Boars. In an Instagram video, he posted his journey through the pitch-black flooded cave, lit only by a few torch-lights.

Speaking to reporters after the news conference, Narongsak said that while Musk’s technology was “good and sophisticated,” it was “not practical for the mission.”

Doctors attending to the eight boys who have been rescued from the cave in two groups of four on Sunday and Monday say they are generally in good health – an incredible result for the boys who have spent nine days incommunicado, without food, until they were found, and then waited days more before embarking on an hours-long dive that even the most skilled cave divers have described as among the most dangerous they have attempted.

A retired Thai navy SEAL died Friday after he ran out of oxygen while placing compressed-air tanks along the exit route.

“Doctors have treated the boys and now all of them are okay and cheerful, and are talking normally,” said Jesada Chokedamrongsuk, from the Thai Ministry of Public Health. One of the boys initially had a heartbeat that was too slow, and some had low white blood cell counts, but they have since been stabilized. Two have been treated for minor lung infections, doctors added. They were all treated for rabies, in case of bats in the cave, and tetanus, and set up with IV drips.

None of them have fevers, and all are able to eat normal “medical” food, the doctor said, an improvement from the watered-down porridge they were fed when they were first rescued. A nutritionist is monitoring their diet and has recommended that they eat nothing spicy or salty – despite the boys’ cravings for spicy basil pork and rice, and grilled pork.

By Monday evening, the boys were able to joke, laugh, and have normal conversation, doctors said. They are still quarantined away from their parents, who have been able to see them through a glass window but not touch or hug them. The boys, however, were visited Monday evening by Thai junta leader and Prime Minister Prayuth Chan-ocha, who was kept about two meters away from the boys.

Follow the Bangor Daily News on Facebook for the latest Maine news.