MAE SAI, THAILAND (NYTIMES) - 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 an underground chamber felt a tug on the rope - the sign that one of the 12 boys and their coach would soon emerge from the flooded tunnels.
"Fish on," the rescuers signalled, said Major Charles Hodges of the US Air Force, mission commander for the US team on site.
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 football 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.
"The whole world was watching, so we had to succeed," said Kaew, a Thai Navy Seal who shook his head in amazement at how every one of the rescues worked. "I don't think we had any other choice."
Interviews with military personnel and officials detailed a rescue assembled from an amalgam of muscle and brainpower from around the world: 10,000 people participated, 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 had been stranded on a rocky perch more than a kilometre underground. Extracting them required long stretches underwater, in bone-chilling temperatures, and keeping them submerged for around 40 minutes at a time. The boys were even given anti-anxiety medication to prevent panic attacks.
"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 in the operation. "So many things could have gone wrong, but somehow we managed to get the boys out."
He added: "I still can't believe it worked."
The risks were underscored last Friday (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.
Thailand's new king donated supplies, and people across the nation volunteered in any way they could, cooking meals for rescuers, operating pumps to suck water out of the cave and hunting for hidden cracks in the limestone formations through which the Wild Boars could perhaps be lifted to safety.
But, most of all, the operation to save the team of 11- to 16-year old boys and their coach, said officials and divers, took bravery.
"I don't know of any other rescue that put the rescuer and the rescuee in so much danger over a prolonged period of time, unless it is something along the lines of firefighters going into the World Trade Centre knowing that the building is on fire and is going to collapse," Major Hodges said.
Tham Luang Cave is a rare place where a person can become completely isolated. There is no GPS, no Wi-Fi, no mobile phone service. The last known survey was conducted in the 1980s by a French caving society, but many of its deepest recesses remain unmapped. Spelunkers consider the cave one of the most challenging in the world.
When the search began, estimates of distances between key points were inaccurate and the location of landmarks uncertain, clouding even the most basic assumptions. Nevertheless, local officials knew enough about Tham Luang's dangers to place a warning sign at the cave's mouth against entering during the rainy season, when flash floods could inundate its chambers.
Rain was forecast for June 23, the day the Wild Boars made their excursion to Tham Luang, but the boys had ventured into the cave before. They left their bikes and football cleats and set off with flashlights, water and snacks bought to celebrate one of the boy's birthdays.
The last of the boys would not emerge until July 10 - more than two weeks later.
By the end of the first night, their parents were frantic. A contingent of Navy Seals began pushing their way into the flooded cave at 4am the next day.
But the Thai frogmen were accustomed to tropical open water, not the murky cold currents racing through the cave. They lacked the equipment, much less the expertise needed for caves, where divers cannot just rise to the surface should something go wrong.
On June 25, Mr Ruengrit Changkwanyuen, a Thai regional manager for General Motors, was among the first volunteer cave divers to show up at the scene. Dozens would follow, from places such as Finland, Britain, China, Australia and the United States.
Even for someone as experienced in cave diving as Mr Ruengrit, the force of the water in Tham Luang shocked him, tearing his mask off when he failed to position himself directly facing the current.
"It was like walking into a strong waterfall and feeling the water rushing at you," he said. "It was a horizontal climb against the water with every move." The Seals and volunteer divers painstakingly penetrated the cave, securing guidelines needed to ensure their safety. They found footprints that hinted at the football team's trail. But as monsoon rain inundated the area, the porous limestone cave absorbed water like a sponge. Once-accessible caverns flooded entirely.
"If you put your hand in front of you, it just disappeared," said Kaew, the Seal who escaped the final deluge. "You couldn't see anything."
Deep within the cave, 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.
On the 10th day, July 2, with little hope of discovering anything but bodies, a pair of British divers working to extend a network of guide ropes popped up near a narrow ledge.
Suddenly, they saw 13 emaciated people perched in the dark. The Wild Boars had run out of food and light but had survived by sipping the condensation from the cave walls.
Elation at their discovery, however, quickly turned to anxiety. Captain Anand Surawan, deputy commander of the Thai Navy Seals who was running an operations centre in Tham Luang, suggested that the boys and their coach might have to stay in the cave for four months until the rainy season subsided.
Three Thai Seals went missing during the operation for 23 hours, and when they finally reappeared, they were so weak from a lack of oxygen that they were rushed to the hospital.
Four days after the boys were found, Mr Saman, the retired Navy Seal who left his airport security job to volunteer, died as he was placing air tanks on an underwater supply route. His family declined an autopsy, but some Thai officials said he ran out of air in his tanks. Others believe he succumbed to hypothermia.
"I'm very proud of him," said Mr Saman's father, Mr Wichai Gunan, a car mechanic. "He is a hero who did all he could to help the boys."
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.
The operation kept shifting with each variable: the water, the air, the mud, even the mental and physical state of the young football players. Because the boys could not swim, they needed full-face masks into which a rich oxygen mix was pumped.
But the masks the US team brought with them were sized for adults. So they tested the gear on volunteer children in a local swimming pool, and discovered that by pulling the five straps as tight as possible, they would work.
The 30-strong US team, which was integral to the planning, 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.
Prime Minister Prayut Chan-o-cha of Thailand said the boys had been given anti-anxiety medication.
"They just had to lay there and be comfortable," said Major Hodges, leader of the US team.
Once the boys completed the underwater portion of their journey, which took around two hours, the going was easier - though still challenging. Navy Seals formed relay teams to lift the Wild Boars down steep slopes on which every step was slippery.
At one point, the plastic bundles containing the teammates 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.
Kaew, the Thai Navy Seal, was standing in the chilly flood of the cave on Tuesday night, swallowing his last bite of seafood-and-pineapple pizza, when he heard the yelled warning: More water was coming fast - get out now.
For three gruelling days, he and his comrades had been hefting the 12 boys and their coach one by one through the series of slick and steep caverns to safety.
Just moments before the warning, he had welcomed back the Seal team that stayed with the boys for eight days on the rock where they had been trapped deep within Tham Luang's flooded maze.
"The boys were safe, and my friends were safe," said Kaew, who was not authorised to give his full name. "I thought, finally, the mission is a success."
Then, when it was seemingly all over, a drainage pump to minimise flooding failed. What had been waist-high water surged to chest level in a vicious torrent where Kaew was standing, about 800m inside the cave's mouth. The Seal, 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 Thai town of Mae Sai saw the last-minute 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."