The head of the Thai Navy Seals has said "hope became reality" with the successful rescue of 12 boys and their coach from the Tham Luang cave.
"We had a little bit of hope that they might still be alive but we had to do it, we just had to move forward," Rear Adm Arpakorn Yuukongkaew told the BBC.
"There was only a tiny bit of hope, but that's all we had to work with."
The group was trapped in the cave by rising water and rescued in a dramatic operation that captivated the world.
The complex, three-day rescue saw four boys emerge on Sunday, four on Monday, and the final four boys plus their coach on Tuesday. They survived the nine days before they were found by drinking water dripping from the cave walls, officials said.
All 13 are now in hospital in Chiang Rai city and receiving medical and psychological assistance, but recovering well.
There were conflicting reports following the rescue about the extent to which the boys had been medicated before they were brought out. The Thai prime minister on Tuesday denied reports that they had been sedated, saying the boys were given only light anti-anxiety medication commonly provided to soldiers.
But sources in the rescue operation told the BBC that the boys were heavily sedated and only partially conscious, and had to be carried throughout the journey out of the cave.
All of the boys lost weight during their ordeal and will remain in hospital for a week, followed by a week's recuperation for another week at home. Public health ministry officials said the first group were all eating normal food and the second group would be put on normal food as of Wednesday.
The third group evacuated on Tuesday are undergoing the same medical check-ups as the first two groups but appeared to also be in good health. There are no cases of serious infections.
The first four boys have already been visited by their families, officials said, and the second group will also be allowed to receive visitors later on Wednesday.
Joy and relief
"We are not sure if this is a miracle, science, or what," wrote the Thai Navy Seals on Facebook on Tuesday. "All the 13 Wild Boars are now out of the cave."
There were cheers around the Tham Luang cave system as the dozens of divers and hundreds of other rescue workers involved in the operation left the site. In the nearby city of Chiang Rai, the news was greeted by the honking of car horns while people gathered outside the hospital broke into applause.
On social media, Thais showed their feelings about the rescuers by using hashtags including #Heroes and #Thankyou. Offers of hospitality for the boys, the coach and their rescuers have come in from international football clubs including Manchester United and Benfica.
How did the drama unfold?
Aged between about 11 and 17, the members of the Wild Boars football team entered the cave system in dry weather, during an excursion with their coach. The group was cut off on 23 June after heavy rains flooded way the cave complex, blocking their way back out.
They were found nine days later when two expert British divers entered the cave. The boys were huddled in darkness on a ledge.
Elation at the discovery of the group quickly turned to concern as it became clear just how difficult it would be to rescue boys who could not swim and had been weakened by their time underground.
A team of expert divers guided the boys and their coach through darkness and submerged passageways towards the mouth of the cave system.
Getting to and from the trapped group was an exhausting round trip, even for experienced divers. The process involved a mixture of walking, wading, climbing and diving along guide ropes.
Wearing full-face masks, which are easier for novice divers than traditional respirators, each boy was accompanied by two divers, who also carried his air supply.
How did the boys survive?
The boys and their coach were trapped underground for a total of 17 days. Officials said the group survived the first nine days of their ordeal by drinking water dripping from the cave walls.
They reportedly entered the cave to celebrate one of the team's birthday, and the snacks they brought with them are thought to have helped sustain them.
Once found, they were given "easy-to-digest, high-energy food with vitamins and minerals, under the supervision of a doctor", said Rear Admiral Arpakorn Yuukongkaew.
According to Thongchai Lertwilairattanapong, an inspector for Thailand's health department, all the children lost on average 2kg during their time underground, but are in good physical condition.
Authorities also said they seemed to cope well with the mental strain of their time underground. Rescue teams brought them lights and letters from their parents to help them cope.
And their coach, Ekapol Chantawong, reportedly taught the team how to meditate to cope with the stress. He trained for a decade as a Buddhist monk before turning to football.
Who are the boys and their coach?
Details have emerged of members of the team and their coach.
Captain Duganpet Promtep, 13, is described as a motivator and highly respected by his teammates. He had apparently been scouted by several Thai professional clubs.
Myanmar-born Adul Sam-on, 14, speaks several languages, and was the only team member to be able to communicate with British divers when they were first discovered.
It was 17-year-old Peerapat Sompiangjai's birthday when the group became trapped in the cave. The snacks the boys brought with them to celebrate are likely to have helped them survive their ordeal.
Assistant coach Ekapol Chantawong, 25, was said to be the weakest of the group when they were found, as he had reportedly refused to eat any of the food and gave it instead to the boys.