Updated

The dramatic three-day rescue of a youth soccer team from a flooded cave in Thailand almost ended in tragedy Tuesday after the main pump reportedly malfunctioned, sending water into the caverns as the remaining rescuers were still trying to get out.

The final four boys and their soccer coach had just gotten out of the cave after the 18-day ordeal just hours before the pump failed as a medic and three Thai navy SEAL divers were making their way out, a U.S. military official who was part of the rescue effort told CBS News.

Maj. Charles Hodges, the U.S. mission commander for the 353rd Special Operations unit for the Air Force, told "CBS This Morning" as three of the SEALS made their way into chamber three of the cave they were told the pumps shut off for an "unknown reason," and that the water levels suddenly started rising. Hodges said that would have cut access off to chambers two, one, and eventually access to get out of the cave.

Cave Evac 4

The last four Thai Navy SEALs who came out of the cave after completing the rescue mission of 12 boys and their soccer coach. (Royal Thai Navy)

"That's an abort criteria for our guys and so when that water level started rising everybody started grabbing their kit and they were ready to get out," Hodges told CBS News. "Thankfully, that last SEAL popped up at the last moment and everyone was able to get out of chamber three safely and make their way out and mission complete. It was a really exciting ending to an awesome mission."

The scramble for crews to clear out of the cave as water levels rose was quite dramatic, as dozens of military personnel and civilians began abandoning the cave, leaving behind hundreds of air tanks that were used in the rescue, Thai military sources involved in the operation told ABC News.

THAI CAVE RESCUE TIMELINE: THE DANGEROUS RACE TO BRING TRAPPED SOCCER TEAM HOME

Hodges said Tuesday that the startling ending to the rescue of the boys was just one of many tense moments during the operation to save the team.

Cave Evac 3

Thai workers clean a giant water pump as they prepare to leave a cave rescue area in Mae Sai, Chiang Rai province, northern Thailand, Wednesday, July 11, 2018. (AP)

"Even though the odds seemed impossible, what I've always been taught is to take risk and be bold when the situation calls for it and this situation absolutely did," he told CBS.

The disclosure of the late risk in the rescue of the team came as health officials released more details on Wednesday about how the group survived during the ordeal.

628d013f-

The team was stranded nearly 3 miles from the cave's entrance.

Thongchai Lertwilairatanapong, a public health inspector, said the 12 boys and coach "took care of themselves well in the cave" and survived by drinking water dripping into their refuge.

The first group of four boys rescued Sunday can now eat solid food and walk around, and the two who have a lung infection are getting better with medicine. The second group of boys rescued on Monday are eating soft food, and some of them have a high white blood cell count, indicating an infection.

The Thai hospital where the 12 boys and their soccer coach are recuperating after being rescued from a flooded cave released video showing them in their hospital beds, smiling and chatting with nurses. The video shows the boys in an isolation ward in beds with crisp white sheets and wearing green surgical masks.

400344f7-thailand kids_hospital AP

The rescued boys can be seen in their hospital room during a police press conference in Chiang Rai province, northern Thailand. (AP)

Chaiwetch Thanapaisal, director of Chiang Rai Prachanukroh Hospital, said during a news conference that "everyone is strong in mind and heart," according to the Associated Press.

Earlier in the day, Thongchai said one member of the final group of four boys and the coach who arrived at the hospital Tuesday evening had a slight lung infection. The average weight loss was 4.4 pounds for those with known information, Thongchai added

Thai Hospital Boy 1

The average weight loss for the boys was 4.4 pounds, officials said. (AP)

"To not receive food, we can still survive for many months -- but what's necessary is water, which the cave has, and around this time there's a lot in the cave, and they chose clean water to drink," he said.

ENTIRE THAI SOCCER TEAM, COACH FREED FROM CAVE AFTER DARING RESCUE

Doctors are still monitoring the boys for certain rare diseases linked to soil, water and animals, but said they are all "lively." Doctors added they think the group is in good shape physically and mentally because of the medical care they received from the SEALS while they were with them in the cave.

Parents of the first group of boys can be in the same room with them, but need to stay several feet away and wear sterilized suits. The parents of the second group of boys may be able to go inside their hospital rooms today, officials added.

c9f39309-

To get the team out, experts had to guide them, diving through the cave's dark, tight and twisting passages.

On Wednesday, Thailand's Prime Minister Prayuth Chan-ocha thanked people involved in the rescue.

In a nationally televised address, Prayuth said that the government's efforts, the assistance of people in Thailand and abroad, and the outpouring of moral support made the mission a success. He also acknowledged the loss of a former navy SEAL, Saman Kunan, who died last week while replenishing air tanks inside the cave.

"His honor, sacrifice and legacy will forever be in our hearts," Prayuth said.

Fox News' Jeff Paul and Melissa Chrise in Chiang Rai, Thailand, and The Associated Press contributed to this report.