With all odds against them, here's how rescuers pulled off 'miracle' Thai cave mission With all odds against them and time running out, rescuer pulled off a miracle.

The steel air tanks glittered under the beams of floodlights as a pair of rescuers defogged their masks and adjusted the straps. They checked their regulators one last time before embarking on what would become their most famous dive.

In the jubilant aftermath of the successful rescues of 12 boys and their soccer coach, the Royal Thai Navy SEALs posted a video on Wednesday showing the miraculous mission as it unfolded over three days deep in the Tham Luang Nang Non cave in northern Thailand.

The first diver wearing a helmet to avoid smashing his head against the mostly low roof the cave gripped a safety rope with a left gloved hand and vanished into the murky water flowing through the narrow passage of the cavern toward where the wayward group was marooned on a small beach.

Meanwhile, rescuers were busy putting one of the boys, fitted with a wetsuit, into a plastic gurney and securing him with ropes before guiding him down from the beach to the water's edge.

It was a mission none of the rescuers had trained for, fraught with so many hazards that those chiefly involved in its execution doubted it would work.

"We train for rescue diving and, at times, we've trained for cave rescue," U.S. Air Force Maj. Charles Hodges, commander for the 353rd Special Operations unit, said Wednesday on ABC's "Good Morning America."

"But we don't ever train for cave-rescue diving," he continued. "I'm incredibly impressed with the way that it worked out, but at the time, candidly, I was thinking that it would be much worse results."

Reported missing

Peerapat Sompiangjai was expected home after soccer practice on June 23. His family had prepared a cake for his 16th birthday and relatives were ready to shower him with presents when he walked through the door. But as the hours passed and he failed to come home, his family grew worried.

The following morning, he still hadn't shown up and his loved ones, along with those of his 11 teammates, reported them all missing.

The boys' bicycles were found lined up at the mouth of the Tham Luang Nang Non cave near where they hold soccer practice, but they were nowhere in sight.

The search party soon learned that 25-year-old Ekkapong Chanwong -- an assistant coach on the missing boys' soccer team, the "Wild Boars" -- had led them on what was supposed to be a fun post-practice expedition inside the cave.

But while the group was exploring the underground maze, heavy monsoon rains struck and flooded all their exits -- forcing the boys and coach deeper into the cave.

International response

The local search-and-rescue official quickly realized that finding the lost athletes would require far more resources than they could muster on their own.

The U.S. Airforce 353rd Special Operations unit in Okinawa was notified and quickly mobilized a group of survival and pararescue specialists that arrived on June 28 at a base camp set up near the mouth of the cave. Soon dive teams and rescue crews from Great Britain, Australia, Japan and China were headed to the Thailand jungle to help.

International dive teams led by the Royal Thai Navy SEALs began combing the cave and the deeper they got the more dire conditions they encountered, officials said.

The terrain inside the cave was challenging, with steep slippery areas, sharp jagged rocks, narrow passages that they had to squirm through and thousands of bats hanging from stalactites. The biggest obstacles were completely flooded passageways that required them to use scuba gear to search further into the cave.

Brainstorming options

News of the ongoing search quickly spread around the world and more equipment and rescue personnel poured into the base camp.

As the underground search continued, geologists began drilling into the cave from outside, searching for hidden openings or areas that looked promising to dig possible escape hatches. But rescuers quickly realized the cave was too deep and the rock too thick to realistically create an alternative way out for those trapped inside.

In Hawthorne, California, billionaire businessman Elon Musk and his SpaceX team came up with an alternative rescue idea. The SpaceX engineers set aside their rocket-making venture and created an experimental kid-size submarine that divers could tow through the flooded passageways to extract the boys once they were found.

The whole time, rescuers in the camp were leaning toward a plan to teach the lost group to scuba dive on the fly in order to get them out if the conditions didn't worsen and they were found alive.

All 13 located

On July 2, ten days after the group went missing, two divers from the British Cave Rescue Council, John Volanthen and Richard Stanton, were stringing a safety rope through a flooded area of the cave when they popped up in a cavern and, to their surprise, saw all 12 boys and their coach huddled on a small beach in the darkness.

Suddenly, euphoria erupted in the base camp, but one big problem existed: How were they going to get them all out alive?

Crews had set up hoses and equipment to pump thousands of gallons of water a day out of the cave to make flooded areas easier to traverse. Other rescuers used jackhammers to widen narrow crevices to make them less complicated to maneuver through. Technicians also worked to install a phone line to where the group was found.

The boys and their coach, who had run out of the little food they had with them when the entered the cave, were given military rations, including chocolate chip cookies, chocolate-covered coffee beans and high-protein gel packs.

"They'd been in the cave for multiple days before they were even found," Maj. Hodges told ABC News. "So, in my mind, the psychological factors were probably some of the most intense issues that were impacting them."

"But understand that every time that one of the rescue divers came back there and they left, we had no communications with them," he said. "For 24 hours or more at a time they would have no contact with the outside world and I'm sure those kids were absolutely scared."

Odds plummet

Narongsak Ostanakorn, the former governor of the Chiang Rai province and head of the search-and-rescue mission, had been worried about the weather from the start. The monsoon rain season in northern Thailand runs from May to November and Ostanakorn was concerned about reports of heavy downpours forecast for the Chiang Rai region.

Some officials had suggested that rescuers wait to extract the group when the weather improved and the cave dried out, so the boys and their coach could just walk out and avoid having to dive their way to safety, since most of them did not know how to swim. But that idea was nixed when oxygen levels plummeted in the cave and the effort to transport the boys enough supplies to survive for weeks -- possibly months -- was deemed unsustainable.

Three days after the group was located, a volunteer diver, retired Thai Navy SEAL Saman Gunan, lost consciousness during an overnight operation delivering extra air tanks inside the cave. He could not be revived and was confirmed dead early Friday morning.

"We were very sad, and we felt like the whole world crashed," Ostanakorn said in an interview with ABC News on Wednesday.

He said other challenges were being thrown at the rescuers. Pumps were not working sufficiently and not enough floodwater was being siphoned from the cave.

Ostanakorn said water was actually rising in the middle part of the cave, threatening to seal off more passageways leading to where the boys and coach were with three Thai Navy SEALs and a medic who was treating their minor injuries and keeping them calm and positive.

Declaring "we are still at the state of war against the water," Ostanakorn and the rescue leaders made the decision late Saturday to execute the plan to bring the group out one by one with divers. It was the only viable option they had.

Attempts failed to put a communication line into the cavern, also known as the "ninth chamber," where the survivors were located. There was no way for rescue crews venturing beyond the third chamber, where a staging area was established, to be in touch with those organizing outside.

"We had to be really smart in how the mission planning went so that everyone knew exactly what their role was," Hodges said. "When they left the third chamber, it was all on them to get the job accomplished."

Rescue begins

At 10 a.m. local time on Sunday, a group of 19 divers entered the cave with about 70 other rescuers and medical teams strategically positioned over the 2.9 miles from the mouth of the cave to where the group waited to be rescued. Air tanks were placed in advance along the route to replenish supplies when needed, officials said.

The video released by the Thai Navy SEALs on Wednesday showed how the final push of the operation unfolded.

Divers prepared their tanks and adjusted air regulators before venturing through a completely flooded passageway on the way to the chamber where the boys and coach were.

One by one, the boys were fitted with wetsuits. One boy was so small that a special wetsuit had to be custom-made for him, Bill Whitehouse, vice chairman of the British Cave Rescue Council, told ABC News.

Each boy was placed on a flexible stretcher and secured tightly with ropes, an air tank positioned at his side, and a breathing regulator fixed to his mouth.

Rescuers inside the ninth chamber had gingerly lowered each boy to the water. The initial plan called for two divers to be tethered to a stretcher containing each rescuee, but as it had gone throughout the mission, adjustments had to be made at the last minute.

"It ended up being normally one diver per boy just because we had a minimal amount of divers," Hodges said.

"They were absolutely wrapped up tight and taken care of well getting out of there," he said of the boys. "This was extremely risky with a low probability of success."

Once through the deep water in which the boys were submerged for up to a half-hour at a time, they were handed off to groups of rescuers who carried them strapped in the stretchers up and down the slippery path, sometimes using ropes and pulleys to move the boys over treacherous expanses along the route. They also used pump hoses throughout the cave as rails to guide the gurneys over the rugged terrain.

At one point, at least 30 rescuers formed a sort of bucket brigade to relay each boy toward the mouth of the cave, where a team of medics was waiting to immediately begin treating them.

At 5:40 p.m. local time, the first boy was finally removed from the cave and rushed to a waiting ambulance. About 10 to 20 minutes later, rescuers emerged with the second boy, followed two hours later by the third and fourth boys.

Day 2 of rescue

"Even though we got four for four the first day, it was not much more than cautious optimism the next day because we knew the risks had not gone down at all," Hodges said.

Luckily for the rescuers, monsoon rains that had been forecast for the area had held off, giving them a chance to pump oxygen into the cave and pump more water out to improve conditions for the second leg of the rescue.

The dive team that had successfully pulled out four boys on Sunday, re-entered the cave on Monday morning.

Ostanakorn said he was pleasantly surprised by how smoothly and swiftly the next four boys were rescued. While Sunday's operation took 11 hours, Monday's rescue took nine hours to complete.

"When the divers finished their mission and were very successful they had a power inside," Ostanakorn told ABC News.

But the weather forecast heightened Ostanakorn's concern and ate away at his nerves. Sleep became a luxury he could not afford, saying he got only 12 hours of shut-eye over the 18-day life-saving mission.

Final Push

"We were concerned about complacency," said Hodges. "So, we were very attentive to making sure that we remained vigilant, but even after we got four for four on the second day, as well, the risks hadn't gone down any at all."

Since the plan had worked well on the first two days, the rescuers followed it when they set out on the last leg of the mission Tuesday with one adjustment: Instead of bringing out four more, they set out to rescue the last four boys and the coach. One of the last boys to leave the cave was also the youngest, 11-year-old Chanin "Tun" Wiboonrungrueng.

In a letter to his family he penned in the cave, Tun wrote, "Dad, Mum, don't worry I'm fine" and requested them to "prepare to bring me fried chicken to eat" once he was rescued.

As classmates of Tun and five other boys at the Maesaiprasitsart School prayed for their safety, rescuers began the final push at 10 a.m. local time Tuesday to save the last five members of the "Wild Boar" soccer team.

Nine hours later, the prayers of the students at the Maesaiprasitsart School were answered.

The announcement the world had been waiting for was made on the Royal Thai Navy SEAL Facebook page around 6:30 p.m. local time: "12 wild boars are out of the cave and their coach. Everyone is safe."

All 13 of the rescuees remained in quarantine on the eighth floor of the Chiang Rai Prachanukroh Hospital Wednesday night. Ostanakorn said they were all happy to be out of the cave in time to watch the last games of the World Cup soccer tournament.

The group has been invited to attend the World Cup final in Moscow on Sunday between Croatia and France, but it's doubtful that all of them will be out of the hospital by then. Ostanakorn said the boys also plan to spend time as monks in a monastery to offer prayers of thanks that they survived.

"Unbelievable," Ostanakorn said of the triumphant rescue.

Just two hours after the last rescue was made and all the crews were pulled from the underground, the skies opened up and a rainstorm hit. The pumps that had been used to remove water from the cave also broke down and the subterranean maze was flooded again.

"If I wait[ed] one more day, I think [it] would have been really difficult for us because the rain is coming," Ostanakorn said.

Although it had nothing to do with soccer, he said the success had everything to do with an international team effort that included the "great divers from the world" and showed what people from different countries and cultures can accomplish when they work together for a single purpose.

"It is not my mission," he said. "It is for the whole team mission. We had 2,000 people here every day that reached for them to come out great and healthy."