The 13 ventured into the Tham Luang cave on June 23 after a football practice and got caught deep inside.

All 12 boys and their football coach, who were trapped in a flooded Thailand cave more than a fortnight, have been rescued, the country's Navy SEAL announced on July 10, completing an astonishing against-the-odds rescue mission that has captivated the world.

The Thai SEAL and elite foreign divers extracted the final batch of four boys, plus the 25-year-old coach, on July 10 afternoon via a perilous escape route that required them to squeeze through narrow, water-filled tunnels.

“All 12 ‘Wild Boars’ and coach have been extracted from the cave,” the SEAL said in a Facebook post.

“All are safe,” they added, signing off with what has become their trademark “Hooyah” to celebrate the successful extractions of other boys over the previous two days.

Also Read Thailand cave rescue: a timeline

A medic and all Navy SEAL divers had also left the cave safely, said chief of the rescue mission Narongsak Osottanakorn.

The 12 boys, aged from 11 to 16, and their coach, ventured into the Tham Luang cave in mountainous northern Thailand on June 23 after a football practice and got caught deep inside when heavy rains caused flooding that trapped them on a muddy ledge.

Nine harrowing days in darkness

They spent nine harrowing days trapped in darkness until two British divers found them, looking gaunt but otherwise offering smiles to the divers and appearing to be in remarkably good spirits.

But the initial euphoria at finding them dissipated as the authorities struggled to devise a safe plan to get them out, with the shelf more than 4 km deep inside the cave and the labyrinth of tunnels leading to them filled with water.

An ambulance leaves the Tham Luang cave area at Khun Nam Nang Non Forest Park in Thailand’s Chiang Rai Province on July 10, 2018. | Photo Credit: AFP

The authorities mulled ideas such as drilling holes into the mountain or waiting months until monsoon rains end and they could walk out, with the rescue chief at one point dubbing the efforts to save them “Mission Impossible”.

With oxygen levels in their chamber falling to dangerous levels and monsoon rains threatening to flood the cave up above the ledge where the boys were sheltering, rescuers decided on the least-worst option of having divers escort them out through the tunnels.

The escape route was a challenge for even experienced divers. The boys had no previous diving experience so the rescuers trained them how to use a mask and breathe underwater via an oxygen tank.

One fear had been that they would panic while trying to swim underwater, even with a diver escorting them.

The death of a former Thai Navy SEAL diver who ran out of oxygen in a flooded area of the cave on July 6 underscored the dangers of the escape route.

Volunteers celebrate near Tham Luang cave complex in the northern Province of Chiang Rai in Thailand on July 10, 2018. | Photo Credit: Reuters

The ups and downs of the rescue bid entranced Thailand and also fixated a global audience, drawing support from celebrities as varied as U.S. President Donald Trump, football star Lionel Messi and tech guru Elon Musk.

Health concerns

Now they are out, concerns are set to focus on the physical and mental toll of the ordeal. Experts warned that drinking contaminated water or otherwise being exposed to bird or bat droppings in the cave could lead to dangerous infections. They also said counselling would be needed to deal with the psychological trauma of spending so long not knowing whether they were going to survive.

A woman lifts her child near the hospital, seen at left, as ambulance transporting members of the children’s football team arrives in the northern Thai city of Chiang Rai on July 10, 2018 after being rescued from the Tham Luang cave. | Photo Credit: AFP

But there were some promising initial signs.

Medical chiefs reported on July 10 morning that the eight boys rescued on July 8 and July 9 were in relatively good mental and physical conditions.

“All eight are in good health, no fever... everyone is in a good mental state,” Jedsada Chokdamrongsuk, permanent secretary of the country’s Public Health Ministry, said before all 13 had been rescued.

Nevertheless, the boys would remain in quarantine in hospital until doctors are sure they had not contracted any infections from inside the cave.

Even before the final rescues, tributes began for the courage of the boys and their ability to survive the ordeal.

“I cannot understand how cool these small kids are, you know? Thinking about how they’ve been kept in a small cave for two weeks, they haven’t seen their mums,” Ivan Karadzic, who runs a diving business in Thailand and has been involved in the rescue mission, told the BBC. “Incredibly strong kids. Unbelievable almost.”