Tham Luang caves, Thailand (CNN) The last remaining member of the Wild Boars soccer team and their assistant coach have been pulled out of a flooded cave in Thailand, bringing an end to a near three-week ordeal that prompted an international rescue effort and captivated audiences around the world.

The 12th boy and his coach were the last of the team to be rescued Tuesday, after a complicated three-day operation to extricate the team, who became trapped on June 23 when rising flood water cut them off deep inside the cave.

In the last 18 days, what began as a local search for the missing 13 turned into a complex rescue operation, involving hundreds of experts who flew in from around the world to help.

The parents of the boys have maintained a constant vigil outside the cave since they went missing, praying for their safe return.

All of the boys and their coach have now been transported to a nearby hospital where eight of their teammates are recuperating after being rescued Sunday and Monday.

The last of the group to emerge from the cave on Tuesday were four Navy SEALs, including a doctor who stayed with the team for a week after their discovery.

"We are not sure if this is a miracle, a science, or what. All the thirteen Wild Boars are now out of the cave," the Thai Navy SEALS said in a Facebook post confirming the entire soccer team had been rescued.

Nineteen divers entered the cave at 10 a.m. local time Tuesday (11 p.m. Monday ET), many on their third mission in three days, with the aim of bringing everyone inside the cave out.

Tuesday's rescue took nine hours in total, from the time the divers entered the cave to bringing out the boys and their coach.

Photos: Photos: Thai soccer team rescued from cave The rescued team attends a news conference in Chiang Rai, Thailand, after being discharged from the hospital on Wednesday, July 18. Hide Caption 1 of 54 Photos: Photos: Thai soccer team rescued from cave Members of the soccer team greet well-wishers as they arrive for the news conference on July 18. Hide Caption 2 of 54 Photos: Photos: Thai soccer team rescued from cave The team poses with a sketched portrait of Saman Kunan, a former Thai Navy SEAL who died on July 6 while returning from an operation to deliver oxygen tanks to the cave. He ran out of air while underwater, an official said. Hide Caption 3 of 54 Photos: Photos: Thai soccer team rescued from cave Thai Navy SEALs pose for a photo after the rescue effort was finished on July 10. One of them was a doctor who stayed with the team for a week after the group was found alive on July 2. Hide Caption 4 of 54 Photos: Photos: Thai soccer team rescued from cave Rescuers carry one of the boys out of the cave. Hide Caption 5 of 54 Photos: Photos: Thai soccer team rescued from cave Divers wave through floodwaters in the cave. Each rescue took multiple hours. Hide Caption 6 of 54 Photos: Photos: Thai soccer team rescued from cave Chiang Rai Governor Narongsak Osotthanakorn speaks during a news conference held after the rescue was finished on July 10. Hide Caption 7 of 54 Photos: Photos: Thai soccer team rescued from cave A helicopter transports rescued boys to the hospital on July 10. Hide Caption 8 of 54 Photos: Photos: Thai soccer team rescued from cave People watch and cheer as a helicopter flies toward an airstrip to transport one of the rescued boys to a hospital. Four boys were rescued on July 8, another four were rescued on July 9, and the rest were rescued on July 10. Hide Caption 9 of 54 Photos: Photos: Thai soccer team rescued from cave Rescue workers leave after all members of the team had been saved. Hide Caption 10 of 54 Photos: Photos: Thai soccer team rescued from cave This photo tweeted by tech entrepreneur Elon Musk shows rescue efforts during the three-day mission. Musk tweeted early July 10 that he had visited the cave and left a mini-submarine there for future use. Hide Caption 11 of 54 Photos: Photos: Thai soccer team rescued from cave Members of the Royal Thai Navy are pictured with the team inside the cave. Hide Caption 12 of 54 Photos: Photos: Thai soccer team rescued from cave The boys received medical attention after being found alive on July 2. Hide Caption 13 of 54 Photos: Photos: Thai soccer team rescued from cave An ambulance believed to be carrying one of the rescued boys heads to the hospital on July 10. Hide Caption 14 of 54 Photos: Photos: Thai soccer team rescued from cave Rescuers walk toward the entrance of the cave as rescue operations resumed on July 10. Hide Caption 15 of 54 Photos: Photos: Thai soccer team rescued from cave Hospital staff and a police officer are seen during a news conference that was held on July 10. The eight boys that had been rescued on July 8 and 9 were being treated in an isolation ward in a Chiang Rai hospital. Hide Caption 16 of 54 Photos: Photos: Thai soccer team rescued from cave Thai police and military officers use umbrellas to shield a rescued boy before he was transported to a hospital on July 9. Hide Caption 17 of 54 Photos: Photos: Thai soccer team rescued from cave An ambulance exits the cave area on July 9. Hide Caption 18 of 54 Photos: Photos: Thai soccer team rescued from cave Emergency responders surround a helicopter on July 8. Hide Caption 19 of 54 Photos: Photos: Thai soccer team rescued from cave Rescue teams arrange a water-pumping system at the cave's entrance on July 7. Hide Caption 20 of 54 Photos: Photos: Thai soccer team rescued from cave Ambulances wait outside a hospital where the rescued boys were treated. Hide Caption 21 of 54 Photos: Photos: Thai soccer team rescued from cave Thai military personnel walk into a cave during rescue operations. Hide Caption 22 of 54 Photos: Photos: Thai soccer team rescued from cave Military personnel work inside a cave. Hide Caption 23 of 54 Photos: Photos: Thai soccer team rescued from cave An ambulance leaves the scene of the rescue effort on July 8. Hide Caption 24 of 54 Photos: Photos: Thai soccer team rescued from cave This undated photo, released via the Thailand Navy SEAL Facebook page, shows rescuers with their hands locked. The caption said, "We Thai and the international teams join forces to bring the young Wild Boars home." The Wild Boars is the name of the soccer team the boys play on. Hide Caption 25 of 54 Photos: Photos: Thai soccer team rescued from cave Family members pray in front of a Buddhist statue near the cave on July 8. Hide Caption 26 of 54 Photos: Photos: Thai soccer team rescued from cave Emergency workers carry oxygen tanks as rescue operations begin. Hide Caption 27 of 54 Photos: Photos: Thai soccer team rescued from cave Thai soldiers work to connect pipes that help water from entering a cave. Hide Caption 28 of 54 Photos: Photos: Thai soccer team rescued from cave Thai forest rangers examine a map as they review their rescue options on July 8. Hide Caption 29 of 54 Photos: Photos: Thai soccer team rescued from cave This image, taken from video on July 2, shows the team trapped inside the cave. That was the day divers found them alive. Hide Caption 30 of 54 Photos: Photos: Thai soccer team rescued from cave Divers were able to bring food, blankets and other supplies to the boys while experts determined the best way to get them out safely. The team was found around two kilometers (1.24 miles) into the cave and somewhere between 800 meters to one kilometer below the surface, according to a British Cave Rescue Council briefing note. Hide Caption 31 of 54 Photos: Photos: Thai soccer team rescued from cave The team was found alive by British divers. The search brought rescue teams from all over the world. Hide Caption 32 of 54 Photos: Photos: Thai soccer team rescued from cave A Thai military medic provides first aid to one of the boys. Hide Caption 33 of 54 Photos: Photos: Thai soccer team rescued from cave The body of Saman Kunan, a former Thai Navy SEAL, is carried during a repatriation and religious rites ceremony on July 6. Kunan died Friday as he returned from an operation to deliver oxygen tanks to the cave. He ran out of air while underwater, an official said. Hide Caption 34 of 54 Photos: Photos: Thai soccer team rescued from cave Thai police take a break for breakfast as rescue operations continue on July 4. Hide Caption 35 of 54 Photos: Photos: Thai soccer team rescued from cave Water is pumped out of the cave on July 3. Hide Caption 36 of 54 Photos: Photos: Thai soccer team rescued from cave Workers fix the road leading to the cave on July 3. Hide Caption 37 of 54 Photos: Photos: Thai soccer team rescued from cave Divers prepare a light to be used for the underwater search on July 2. Hide Caption 38 of 54 Photos: Photos: Thai soccer team rescued from cave Rescue workers wait at the entrance to the cave on July 2. Hide Caption 39 of 54 Photos: Photos: Thai soccer team rescued from cave Some of the team's family members celebrate after receiving news that the team was alive. Hide Caption 40 of 54 Photos: Photos: Thai soccer team rescued from cave Technicians lift water pumps to the drilling site on July 1. Hide Caption 41 of 54 Photos: Photos: Thai soccer team rescued from cave Soldiers and rescuers work outside the cave complex on July 1. Hide Caption 42 of 54 Photos: Photos: Thai soccer team rescued from cave Monks attend a Buddhist prayer for the team on July 1. Hide Caption 43 of 54 Photos: Photos: Thai soccer team rescued from cave Scuba tanks are delivered to the search site on July 1. Hide Caption 44 of 54 Photos: Photos: Thai soccer team rescued from cave Rescue workers carry water-pumping equipment into the cave on July 1. Hide Caption 45 of 54 Photos: Photos: Thai soccer team rescued from cave A Thai Air Force worker drops near a possible cave opening on June 30. Hide Caption 46 of 54 Photos: Photos: Thai soccer team rescued from cave British cave diver Robert Charles Harper explores an opening on June 29. Hide Caption 47 of 54 Photos: Photos: Thai soccer team rescued from cave Relatives of the trapped team members pray on June 27. Hide Caption 48 of 54 Photos: Photos: Thai soccer team rescued from cave Family members waited more than a week for news of their loved ones. Hide Caption 49 of 54 Photos: Photos: Thai soccer team rescued from cave Thai soldiers bring hoses and additional water pumps as the search for the team continued on June 27. Hide Caption 50 of 54 Photos: Photos: Thai soccer team rescued from cave Volunteer paramedics wait near the cave entrance on June 27. Hide Caption 51 of 54 Photos: Photos: Thai soccer team rescued from cave A rescuer looks for a cave entrance on June 27. Hide Caption 52 of 54 Photos: Photos: Thai soccer team rescued from cave Rescuers search the cave on June 26. Hide Caption 53 of 54 Photos: Photos: Thai soccer team rescued from cave Thai soldiers relay cable at the search site on June 26. Hide Caption 54 of 54

'I can sleep well now'

Nopparat Kanthawong, the team's head coach, told CNN the wait for the boys and their assistant coach to be rescued has been agonizingly slow.

"I'm happy a lot more than other days because we were waiting for this day for a long time," he said in an interview late Tuesday at his house in northern Thailand's Mae Sai District.

He added: "I can sleep well now and have good dreams at least for this one night."

Kanthawong said he didn't know the players and coach were going into the cave.

"At this time, now that the coach is out, just wait until he gives any statements and let's just wait altogether and find out (why they went into the cave) at the same time," he said.

Kanthawong said he is eager to comfort his players now that they are safe.

"I'm going to give them a hug," he said.

Rescued boys recovering in hospital

Earlier Tuesday, more details emerged about the ages and condition of the children already freed from the cave.

All eight boys rescued on Sunday and Monday are being treated in an isolation ward in a Chiang Rai hospital. Medical officials told reporters Tuesday that they're healthy, fever-free, mentally fit and "seem to be in high spirits."

Some of the boys have even asked for bread with chocolate spread -- which they were given, said Jedsada Chokedamrongsook, the permanent secretary of the Thai Health Ministry. But they'll mostly be eating a food similar to milk and rich in proteins and nutrients.

Chokedamrongsook said the first group of boys taken out on Sunday were aged 14 to 16. Their body temperatures were very low when they emerged, and two are suspected of having lung inflammation.

Families of the first four have been able to see their children through a glass window, Chokedamrongsook said. They were also able to talk on the phone. They'll be allowed to enter the room if tests show the boys are free of infection.

Thai hospital staff and a police officer at Chiang Rai Prachanukroh Hospital on Tuesday.

The second group freed on Monday were aged 12 to 14. One had a very slow heartbeat but had responded well to treatment, Chokedamrongsook said. The hospital has sent test samples from the boys to a lab in Bangkok.

Authorities will likely look for signs of Histoplasmosis, also known as "cave disease," an infection caused by breathing in spores of a fungus often found in bird and bat droppings.

They are all likely to stay in hospital for up to a week, due to their weakened immune systems. Thai Prime Minister Gen. Prayut Chan-ocha visited the hospital Monday, and spoke to relatives and hospital workers.

Prime minister Prayut Chan-ocha gives support to families of the rescued boys and thanks hospital staff for taking care of the Wild Boar soccer team members being treated at Chiang Rai Prachanukroh hospital.

Shortly after the news of the boys' safe return broke, US President Donald Trump tweeted his congratulations to the Navy SEAL team.

"On behalf of the United States, congratulations to the Thai Navy SEALs and all on the successful rescue of the 12 boys and their coach from the treacherous cave in Thailand. Such a beautiful moment -- all freed, great job!"

On behalf of the United States, congratulations to the Thai Navy SEALs and all on the successful rescue of the 12 boys and their coach from the treacherous cave in Thailand. Such a beautiful moment - all freed, great job! — Donald J. Trump (@realDonaldTrump) July 10, 2018

Treacherous conditions

Divers involved in the rescue described treacherous conditions, with fast-moving shallow water passing through very narrow passages.

"This is the hardest mission we've ever done. The lower the water is getting, the stronger the current. It's stronger now. Every step of the extraction is risky," said Narongsuk Keasub, a diver for the Electricity Generating Authority of Thailand.

He's one of a group of divers whose job is to transport air tanks into the tunnels for the SEAL teams. Before the final rescue, he told CNN that divers inside the cave faced a number of challenges.

"We can only see our hands (at a) short distance. Secondly, the stones are razor sharp which is dangerous for our diving, (and) thirdly the passage is very narrow," he said.

JUST WATCHED Rescue diver: Every step of extraction is risky Replay More Videos ... MUST WATCH Rescue diver: Every step of extraction is risky 01:51

Keasub said that the thought of their own children kept them going. "I'm quite emotional as a father -- everybody has this feeling because we feel like it's our children who are inside the cave."

A dangerous journey

For several days, rain threatened to hamper what was already a complicated rescue mission. When it became clear the boys were likely going to have to dive out, experts were sent in to teach them how to use scuba gear.

Officials sourced full-faced oxygen masks small enough to fit the boys, to remove the chances of them falling off during the long arduous journey through the craggy tunnels.

Thailand cave rescue

Saturday, June 23 12 members of the Wild Boar soccer team and their coach become trapped in a Thai cave by monsoon rains.

Monday, July 2 British divers find the boys, aged 11 to 16, and their coach on a rocky ledge, 4 kilometers inside the cave.

Friday, July 6 A former Thai Navy SEAL dies from lack of air while delivering oxygen tanks inside the cave.

Sunday, July 8 The first group of 4 boys are rescued and moved to Chiang Rai Prachanukroh Hospital.

Monday, July 9 Four more boys are rescued and taken to hospital.

Tuesday, July 10 All remaining boys and their coach are freed and taken to hospital.



Source: CNN reporting

Two days before the first four boys were rescued, officials warned that oxygen levels with in the cave had fallen to 15%.

Forecasts of more rain also threatened to raise water levels, further educing the amount of available air and jeopardizing efforts to get the boys out. However, a few days of relatively clear skies allowed rescuers to pump enough water out of the cave to allow the boys to walk through some sections.

During the hours-long trip out of the cave, each boy was accompanied underwater by two divers helping them navigate the dark, murky water. The most dangerous part is the first kilometer, during which the divers and boys are required to squeeze through a narrow, flooded channel.

Rescuers needed to hold the boys' oxygen tanks in front of them and swim pencil-like through submerged holes. Having completed this section, the boys are then handed over to separate, specialist rescue teams, who help assist them through the remainder of the cave, much of which they can wade through.