Finding the missing football team was the first major challenge. The next part is bringing all 12 boys and their coach out safely through the flooded caves and narrow passageways.
Complicating the rescue will be the team's weakened condition after days without food, and potentially other health problems. Further heavy rain, which has bedevilled the rescue mission from the start, could also hamper their extraction.
Late last night, rescue officials met to try to determine the safest way to bring all 13 back home to their families, who have had an agonising wait for news.
Chiang Rai Province Governor Narongsak Osottanakorn confirmed that the boys - aged between 11 and 16 - and their coach were alive, but that he did not know their exact condition.
He said rescue workers were trying to care for the boys and get them fit enough to be moved.
Thai Seal divers were able to advance deep into the cave system to reach the team because the rescuers were supplied with enough oxygen tanks to last several hours. But for the boys to dive out, under muddy water, could be risky.
Rescuers were working yesterday to clear a constricted passageway for divers deep inside the flooded cave complex in a search operation that had been hampered by heavy rain.
Divers from the Thai Seal unit had been focusing on an elevated mound inside the cave which cavers have named "Pattaya Beach". It could have provided the boys with a refuge when heavy rain flooded the cave.
"The Seals reported that... they reached Pattaya Beach, which was flooded. So they went 400m further, where we found the 13... who were safe," Mr Narongsak told the cheering group of reporters. They were found about 4km from the cave entrance.
Thai Prime Minister Prayut Chan-o-cha thanked the international effort that came together to look for the team.
The search had attracted global attention and came during the World Cup, with several teams expressing their support for the search.
Loved ones, friends and teachers of the "Wild Boars" football team refused to give up hope of seeing the young players again, holding an increasingly desperate vigil at the cave entrance.
Parent Tinnakorn Boonpiem, whose 12-year-old son Mongkol is among the 13, said: "I am so glad... I want him to be physically and mentally fit. I am afraid he will be mentally affected by this incident."