CHIANG RAI, Thailand (NBC) — After 17 long nights trapped in a dark and damp cave, four remaining boys and their soccer coach were freed one-by-one by divers in Thailand on Tuesday.

Rescuers started the day hoping to help the final five who had been stranded for more than two weeks reach the surface and safety. The first of the group emerged Tuesday afternoon local time with the others following soon after, ending an eight hour and 10 minute operation.

“We are not sure if this is a miracle, a science, or what. All the 13 Wild Boars are now out of the cave,” the Thai navy SEALs posted on Facebook, referring to the name of the boys’ team.

The medical condition of the boys rescued Tuesday was not immediately known. Officials previously said that the healthiest boys would be brought out first.

The complicated operation started Sunday when expert divers rescued the first four boys. They then went back in on Monday and retrieved four more.

With experience under their belts, Tuesday’s operation was completed hours faster than before.

A medic and three Thai navy SEALs who had stayed deep inside the mountain since the 13 missing males were found on July 2 also needed to navigate the narrow, water-logged passages in the cave complex. As of 8 a.m. ET, they had not yet returned to the surface.

The boys vanished on June 23 with their 25-year-old coach after seasonal rains flooded the caverns and narrow passages, blocking their exit from the popular tourist destination. Nine days later, two expert cave divers found the trapped group.

A Thai-led international group of rescue and diving specialists then started planning the best way to free the group.

At 10 a.m. local time (11 p.m. ET Monday) on Tuesday, 19 divers entered the caves. Another 100 divers and rescuers, along with ambulances and other vehicles were in the area as the operation began.

The initial eight who were freed are currently in good health, officials said Tuesday. They were receiving medical treatment at a hospital in Chiang Rai.

Jetsada Chokdumrongsuk, a public health official, told reporters that the boys were given antibiotics, rabies vaccines and vitamin B2 and showed no signs of fever or vision problems.

They could communicate normally and were able to stand up, walk around and get dressed themselves, he said. They even chatted with Prime Minister Prayut Chan-o-cha when he came to the hospital.

X-rays revealed that two of the boys had suspected lung infections, but doctors were awaiting lab tests, Jetsada said.

In an effort to control infection, doctors were not allowing visitors. Positive test results would mean face-to-face visits between the boys and their families would be possible at the hospital.

So far, only the first group of four boys — ages 14 to 16 — have been able to see their families through glass windows, Jetsada said.

“They’re homesick and they miss their parents, and they’re very happy to be here,” he added.

This boys were “often hungry” during their ordeal and they “need a lot of food,” Jetsada said, adding that they have requested bread and chocolate spread. They’ve been given soft, easily digestible medical-grade food that is high in nutrients.

After divers discovered the group in the caves last week, they were given energy gels and baby food to help their bodies slowly adjust to solids.

The second group, ages 12 to 14, were all hospitalized with low body temperatures, though they’d since stabilized.

It could be another week before the boys are released from the hospital, officials said.

Rachel Elbaum reported from London, and Bill Neely from Chiang Rai, Thailand.