CHIANG RAI, Thailand — With a routine of digging, water breaks and meditation, a group of young Thai soccer players and their coach stayed alive while trapped in a flooded cave without any food for nine days before they were found by two British divers.

In their first public appearance since a daring rescue operation that riveted the world, the players emerged Wednesday in their team uniforms, holding soccer balls and dribbling them in a show of health and good spirits. Then, smiling and bowing before television cameras with friends and families close by, they detailed their long ordeal, recounting in a news conference the most harrowing moments of their ad­ven­ture gone wrong.

The 12 boys persuaded their 25-year-old assistant coach, Ekapol Chanthawong, to bring them on a short trip into the vast Tham Luang cave system after soccer practice on June 23. They had no food with them, Ekapol said, and planned to stay there for just an hour and be home before nightfall. One of the boys had to get back for a lesson with a private tutor; another had a birthday celebration awaiting him.

Some of them were familiar with the cave’s vast rock fields and crevices and had gone far into its passageways before. But for others, it was their first trip. None of the boys had told their parents of their plans. 

When they arrived, water from seasonal monsoon rains had already begun pooling just beyond the cave’s mouth. Ekapol asked the boys whether they wanted to go on, and they did. They went farther in — to a point where they would have to swim to venture any deeper inside the cave network, the coach said.

They had planned to keep exploring, but they realized it was getting late and turned back, hoping to get out the way they came in. They quickly found that the floodwaters had blocked their exit.  

Ekapol tried out their only escape path. He told the elder boys to hold on to a guide rope and waded deep into the water. If they felt two tugs, it meant he was stuck and needed to be pulled out. 

“I walked inside that hole of water,” he said. “It felt like there was just stone all above me, and only sand under my feet.” He tugged twice, and the boys pulled him out. 

“I told them we couldn’t get out that way and had to find a new way,” he recounted. 

The team found shelter instead, prayed before sleeping that night and hoped the water levels would drop enough for them to swim out the next day. Ekapol, the only adult among them, said he was sure there would be a way out then. The boys’ reactions ranged from panic to guilt to optimism, he said.

That was the first of nine days that the soccer players and their coach had to go without food, trapped in the cave system in a lush mountain range in northern Thailand, close to the border with Myanmar, also known as Burma. As the hours passed, they lost track of how long they had been in the cave’s dark chambers. Faced with a group of hungry, weakening boys, Ekapol urged them to drink water to keep full and to try to dig holes out through the cave with rocks, so that they had a sense of purpose. 

“We dug holes to find a way to escape and stopped when we were tired. We kept drinking water to fill our belly,” the assistant coach said. 

The boys ranged in age from 11 to 16. The youngest of them — Chanin Wiboonrungrueng, known by his nickname, Titan — said he soon started to feel faint and dizzy, and struggled to keep his mind off food. 

“We tried not to think of food, like fried rice, because it would make us hungrier,” he said. 

On their fifth day in isolation, the players and their coach discussed their options: going deeper into the cave’s winding passageways in hopes of finding an exit farther along; diving out the way they had come; or waiting. Many of them could swim — contrary to initial reports — and so they tried to venture out. At the cave’s intersection, they saw waters rising and knew that was not an option. They were trapped and retreated again by climbing higher up. They decided not to move anymore and continued to dig instead.

“We couldn’t go out, but we could dig,” Ekapol said. “At least we were doing something.” 

On Day 9 since their disappearance, some of the boys were on their digging routine when they heard a voice. Ekapol — “Coach Ek,” as he was known to the boystold them to be quiet and sent one of the boys down from their dry ledge with a flashlight, closer to the water’s edge. The coach asked him to hurry, afraid a rescuer would miss them.

Adul Sam-on, an English-speaking polyglot migrant from Myanmar, realized that the two divers who suddenly emerged were foreigners and spoke English, but he could not find the right words to say to them, except “Hello.”

“My brain was working very slowly,” Adul, 14, said. “All the words left my head.” 

The two British divers who called out to them, Rick Stanton and John Volanthen, offered a “ray of hope,” the boys said. Volanthen, checking that all of the 13 missing were there, still alive, assured them that Thai navy SEALs would come with “food and doctors and everything.”

The disappearance of the boys and their novice-monk-turned-soccer-coach from the small town of Mae Sai on the Thai-Myanmar border launched an international rescue effort involving thousands of divers, rescuers, cave experts, and Thai and foreign military personnel. The plan to extract them by diving them out of the cave’s flooded passageways ended with the successful rescue of all 13, who were then sent to a hospital to recover. They were discharged Wednesday, almost a month after they first disappeared. On average, each boy had gained about 6  1/ pounds since the rescue.

The Thai navy SEALs who stayed with the lost team until the rescue said Wednesday that they worked to keep the boys’ spirits up and ensure they were in good health. Wearing hats and sunglasses — Thai SEALs are not identified due to the nature of their work — they said they gave the boys high-protein rations and played chess with them to pass the time.

The SEALs used food as motivation, reminding the boys of all the treats that awaited them when they returned home.

“They were like my brothers, like my family,” Ekapol said of the SEALs. “We ate together, and we slept together.” 

At the news conference, the boys paid tribute to former Thai navy SEAL Saman Kunam, a rescuer who died laying compressed-air tanks in the cave’s flooded passageways.  Ekapol said he blamed himself for the  diver’s death.

“I will live my life very carefully from now on, to thank everyone” for their help, he said. All the boys and their coach will be ordained in a Buddhist monastery for nine days in tribute, a Thai tradition.

Psychologists urged journalists and the public to allow the boys to have a normal life as they return to their modest homes after 25 days. Many are bracing for scoldings, and they took turns apologizing.

“Sorry for being so naughty that I didn’t tell my parents about going into the cave,” one boy said. Another added: “If I had let them know, there’s no way they would have let me go.”

Mahtani reported from Singapore.