MAE SAI - Improbably enough, most of the escapes went flawlessly. But on trip No. 11 to save one of the last football teammates stuck for 18 days deep inside the cave, something went dangerously wrong.
Rescuers inside the underground chamber felt a tug on the rope - the sign that one of the boys would soon emerge from the flooded tunnels.
Fifteen minutes went by. Then 60. Then 90.
As the rescuers waited anxiously, a diver navigating the 11th teammate through the underwater maze lost hold of the guide rope. With visibility near zero, he could not find the line again. Slowly, he backtracked, going deeper into the cave to find the rope, before the rescue could resume.
At last, the survivor got through - safely.
It was a frightening moment in what had been a surprisingly smooth rescue of the soccer team, the Wild Boars, who had survived the murky darkness of Thailand's Tham Luang cave, sometimes by licking water off the cold limestone walls.
Interviews with military personnel and officials detailed a rescue assembled from an amalgam of muscle and brain power from around the world: 10,000 people took part, including 2,000 soldiers, 200 divers and representatives from 100 government agencies.
It took plastic cocoons, floating stretchers and a rope line that hoisted the players and coach over outcroppings.
The boys and their coach had entered the cave on June 23 and became stranded on a rocky perch after heavy rain flooded parts of the cave complex. Extracting them required long stretches underwater, in bone-chilling temperatures, and keeping them submerged for around 40 minutes at a time.
"The most important piece of the rescue was good luck," said Major-General Chalongchai Chaiyakham, deputy commander of the Thai 3rd Army Region, which helped the operation. "So many things could have gone wrong, but somehow we managed to get the boys out. I still can't believe it worked."
The risks were underscored on July 6 when retired navy Seal Saman Gunan died in an underwater passageway. Three Seal frogmen were hospitalised after their air tanks ran low. Swift currents pushed divers off-track for hours at a time, sometimes tearing off their face masks.
More than 150 Thai navy Seal members, outfitted with improvised equipment sometimes held together with duct tape, helped create the escape route. A crew of foreign and Thai cave divers courted death every time they explored Tham Luang's cramped chambers.
Overseas military teams brought search-and-rescue equipment. The Americans provided logistics, while British divers navigated the most hazardous stretches.
The Seals and volunteer divers painstakingly penetrated the cave, securing guidelines needed to ensure their safety. As monsoon rain inundated the area, the porous limestone cave absorbed water like a sponge. Once-accessible caverns flooded entirely.
The water was so cold that the Thai divers' teeth chattered while they rested during 12-hour shifts. Lacking proper helmets, the Seals taped a medley of flashlights to their improvised headgear.
"If you put your hand in front of you, it just disappeared," said Kaew, a Thai navy Seal. "You couldn't see anything."
Meanwhile, efforts to drain the cave, through pumps and a makeshift dam, began producing results. Crags and outcroppings emerged from the murk. The most waterlogged passage, which had taken five hours to navigate in the early going, could now be traversed in two hours with the help of guide ropes.
By last weekend, the rescuers were eager to act. Rain was back in the forecast. The oxygen level where the boys were sheltering had dipped to 15 per cent. At 12 per cent, the air would grow deadly.
Mr Erik Brown, a 35-year-old Canadian who was one of 13 foreign expert divers in a core rescue team of 18, said he was terrified as he swam, crawled and waded through the labyrinthine cave. He recalled diving for perhaps half an hour in "zero visibility", with his helmet bashing against rocks, and then a 10-minute walk in water up to his waist before diving again.
Mr Brown was tasked during the rescue with changing oxygen tanks and hauling the boys along between dive spots.
During the rescue, the boys were fitted with 5mm-thick wetsuits and full-face scuba masks. They were told to remain calm and motionless as two divers prepared to tug them through murky waters and along guide ropes that had been put in place.
The 30-strong US team recommended that each child be confined in a flexible plastic cocoon, called a Sked, which is marketed as a rescue stretcher and is a standard part of the air force team's gear.
British cave divers navigated the wrapped boys through the trickiest underwater passages, while monitoring for air bubbles that proved they were breathing.
Not one of the children was a strong swimmer, let alone competent diver. Some crevices were barely wide enough for a person, and the swirling currents risked ripping off the boys' oxygen masks.
"The main challenge in the mission is water, which keeps coming all the time. This makes the current inside quite strong, and because it is constantly flowing, the water is murky," a Thai officer involved in the mission told Reuters.
About 40 per cent of the boys' journey through the water of at least three hours involved diving, and in other parts, water was up to the rescuers' chests, said Thai navy Seal commander Rear-Admiral Apakorn Yuukongkaew.
Once past this stretch, they reached Chamber Three. The diving was over by this point, but still the way ahead was hard.
The boys were put in green plastic toboggans and carried through: At some points, there were steep slopes with cascading water, and the rescuers had to use a pulley system to winch them up. "We didn't want the children to walk because it is really tiring from Chamber Three to the cave mouth," Rear-Adm Apakorn said.
Wet and cold, some of the boys fell asleep as they were hauled along to the exit, but there were more than 100 people stationed along this section, including nurses who checked their temperature, blood pressure, pulse and oxygen levels.
At one point, the plastic bundles containing the boys were placed on the hoses for the water pumps, which acted as an impromptu slide. Rope lines hoisted the football team aloft so they could swing past particularly craggy parts of the cave. In one leg of the escape, the cocoons were placed on floating stretchers, and Thai frogmen pushed them along.
"We brought the children out like eggs protected in stone," Rear-Adm Apakorn said, referencing a Thai saying equivalent to "velvet glove".
Over three gruelling days, the boys and their coach emerged, one by one, from the cave safely.
Then, when it was seemingly all over, a drainage pump to minimise flooding in the cave failed.
"The boys were safe, and my friends were safe," said Kaew, the Thai navy Seal. "I thought, finally, the mission is a success."
Kaew had welcomed back the Seal team that stayed with the boys for eight days on the rock, moments before the pump failed. What had been waist-high water surged to chest level where Kaew was standing, nearly a kilometre from the cave's mouth. Kaew, who had no scuba gear with him, scrambled to higher ground, barely escaping the final deluge.
It was a chaotic finale to the rescue. Many of the divers and residents of the nearby northern town of Mae Sai saw the last flood as a sign that divine protection had ceased only after all were safe.
For the entire mission, Kaew had wrapped a Buddha amulet hanging on his neck with waterproof tape. "The cave is sacred," he said. "It was protected until the very end."