MAE SAI, THAILAND (NYTIMES) - It began as a misadventure by 12 boys and their football coach in a flood-prone northern Thai cave, which soon seemed destined to end in tragedy.
It turned into a nearly three-week-long story of survival, international collaboration and triumph over the impossible - one that was avidly embraced and followed live across the world.
A team of cave divers rescued the last of the boys and their coach on Tuesday (July 10) from deep inside the warren of underground passages near Thailand's border with Myanmar, one of South-east Asia's more remote regions.
One by one, the divers brought the final four members of the Wild Boars team and their coach out of the flooded Tham Luang Cave.
How they did it was a mix of trial and error, improvisation, skill, massive water pumps, miles of guide rope and strategically placed air tanks along the 5km-long escape route, much of it submerged.
It took 10 days for rescuers to even find the boys, then nearly a week before the rescue could begin.
One diver, a former Thai Navy Seal, died while preparing the evacuation.
The other rescuers, laden with scuba gear, carried the boys - who could not swim and wore full-face masks - as they squeezed through flooded crevices that would challenge the most seasoned divers.
The final trek to freedom took four hours or more per child.
"We are not sure if this is a miracle, or science, or what," the Thai Navy Seals posted on their Facebook page.
"All the 13 Wild Boars are now out of the cave."
The rescue of the Wild Boars touched a global nerve, an uplifting counterpoint to the wars, atrocities, ethnic conflicts and crises afflicting countries such as Syria, South Sudan and Yemen - not to mention closer to home in Myanmar and in Thailand itself, where there is a long-running war near the southern border.
For many people around the world, Thailand's extraordinary operation to save 12 boys and their coach was a welcome contrast to the images of the United States separating immigrant children from their parents and locking them up.
The five Wild Boars who emerged on Tuesday were immediately taken by ambulance and helicopter to a hospital in Chiang Rai, the nearest large city, and were to be placed in quarantine with the eight boys rescued on Sunday and Monday.
They were expected to stay for about a week in quarantine, where family members who once feared they were dead can see them through a window.
Among the last to emerge from the cave was the Boars' 25-year-old football coach, Ekkapol Chantawong, who helped the boys stay alive by conserving their energy during the 10 days before aid arrived.
Family members and friends were predictably ecstatic over the news that everyone was finally safe. Hundreds of millions of others around the world cheered with them.
"It was 18 days but it felt like years," said Prayuth Jetiyanukarn, the abbot at a temple in the town of Mae Sai where Ekkapol works.
The abbot's eyes welled.
"I'm so happy, but it's not just for Ek and the team," he said. "The whole world has been watching over these 18 days and they are celebrating with us."
At a packed news conference after the rescue, the chief of the operation, Narongsak Osatanakorn, was visibly pleased.
"We have done something that no one expected that we could complete," he said.
"It was an impossible mission."
Also making their way out of the cave were four Thai divers, an army doctor and three members of the Thai Navy Seals who had stayed in the cave with the Boars for more than a week after they were found and helped them prepare for their underwater escape.
Narongsak said that all four divers were healthy after eight days underground. They are expected to join the Wild Boars and Ekkapol in quarantine, however, because of the fear of infection.
"This morning, I promised to take nine people out," Narongsak said. "We're a success now." Tham Luang Cave, about 3km from the border with Myanmar, is the bed of an underground river that flows during the monsoon season.
The cave is also a maze of passageways and chambers, with side routes and dead ends that make it formidable to navigate, especially when filled with water.
Just reaching the cavern where the group ultimately took refuge was a feat even for the most skilled searchers.
The Wild Boars and their coach entered the cave after football practice on June 23, a week before the rainy season generally begins.
But a heavy rain started falling and the cave complex quickly began to fill with water, forcing them deeper into the maze to avoid drowning.
Narongsak, then the governor of Chiang Rai province, began organising a search, a task that he later said seemed hopeless.
Nonetheless, Narongsak and other officials threw themselves into it. They mobilised dozens of members of the Thai Navy Seals, hundreds of soldiers, volunteers and workers from 20 government agencies.
Leaders of the operation tried every approach they could devise.
Some failed, such as searching for a back door to the cave or drilling holes from the mountain above in the hope of lifting the boys out.
But two made a big difference: Installing massive pumps to drain water from the cave and building an improvised dam to keep flood waters from flowing in.
To help the members of the Navy Seals, who had little experience in cave diving, search leaders turned to a group of highly skilled foreign cave divers, a rare breed of explorers.
The boys and their coach were finally found on July 2 by two British divers who were extending guide lines into the cave.
One diver, John Volanthen, reached the end of his line, fastened it in the mud and emerged from the water to find 13 pairs of eyes staring at him.
The boys, having no idea of the international fixation over their plight, were surprised to learn that the diver was from Britain.
Had Volanthen's line been 4.5m shorter, he would most likely have missed them.
The boys requested food and asked whether they could leave right away. But that operation would take another six days to start, and two more before all were evacuated.
Four Thai divers stayed with them, nursing them back to health and feeding them a high-protein diet.
Officials said that extracting the boys through the treacherous underwater passageways would be more difficult than finding them. Few, if any, of the boys knew how to swim, much less use diving gear.
Ultimately, the rescue officials concocted a plan to have small teams of divers bring out the boys by holding them under their bodies as they swam. The boys wore full-face masks, rather than scuba gear, to make it easier for them to breathe underwater.
A successful rescue depended on positioning a supply of air tanks along the route they would take.
Disaster struck last Friday when a volunteer diver, Saman Gunan, 38, a former member of the Thai Navy Seals, lost consciousness and died as he returned from putting air tanks in place.
"I call him the hero of Tham Luang Cave," Narongsak said.
On the first two days of the rescue, 18 divers - 13 foreigners and five Thai - took part, bringing out four boys each time. On the final day, at least 12 divers took part.
Jintrakarn Sriwanithkul, 18, a student at the Mae Sai Prasitsart School attended by six of the Wild Boars, grew excited at word of the rescue.
"It's amazing news," he said.
"When I first heard about them being missing, I thought they'd come out in two to three days because they knew the cave well."
Foreign journalists converged on the cave by the hundreds in the kind of mass coverage usually reserved for major news events, like the disappearance of Malaysia Airlines Flight 370 four years ago.
For Thailand's military leaders, who seized power in a coup the same year and have yet to hold promised elections, the rescue was an opportunity to show their concern for residents of the country's northernmost province.
King Maha Vajiralongkorn Bodindradebayavarangkun, who let it be known early on that he was closely following the search effort, donated food and supplies.
Whether the King's unusual personal interest gave added impetus to the effort is unclear. But a top police official who visited the cave told search leaders to spare no expense.
Prime Minister Prayut Chan-o-cha, a former general, visited the cave twice to meet officials, rescue workers and families of the missing boys.
He assured relatives that the government would not abandon them.
In the end, the final rescue part of the mission took just under nine hours, starting from the time the divers entered the cave to the time they emerged with all four boys and Ekkapol.
"I would like to say thank you to His Majesty and royal family to support us," Narongsak said. "I am thankful for all support from Thai people and all around the world."
Some members of the Thai Navy Seals stayed near the cave at quarters in Mae Sai. By the end, scuba gear, boxes of instant noodles and wet towels were strewn all around.
One member of the Seals said that the operation might have looked easy from the graphics in newspapers but that it was tough. They worked 12-hour days at a minimum and returned to quarters exhausted.
Nangnoung Namun, a weaver by trade who cooked hundreds of meals a day for the Seal team as a volunteer, was elated by the rescue.
"Now I can sleep peacefully," she said. "I'm so relieved."
The first confirmation that all 13 were finally safe came from the Seal team with a post on their Facebook page shortly before 7pm.
"12 boars and coach are out of the cave," they announced.
"Everyone is safe." "Hooyah," the Facebook post concluded.