Follow KDKA-TVFacebook | Twitter

MAE SAI, Thailand (AP) — All 12 boys and their soccer coach have been rescued from a flooded cave in northern Thailand, the Thai navy SEALs said Tuesday, ending an 18-day ordeal that riveted people around the world.

The SEALs, who were central to the rescue effort, said on their Facebook page that the remaining four boys and their 25-year-old coach were all brought out safely Tuesday. Eight of the boys had been brought out of the cave by a team of Thai and international divers on Sunday and Monday.

“We are not sure if this is a miracle, a science, or what. All the thirteen Wild Boars are now out of the cave,” the SEALs said, referring to the name of the boys’ soccer team.

“Everyone is safe,” they said.

They said they were waiting for a medic and three SEALs who had stayed with the boys in their dark refuge deep inside the cave complex to come out.

Cheers erupted at a local government office where dozens of volunteers and journalists were awaiting news of whether the intricate and high-risk rescue mission had succeeded. Helicopters taking the boys to a hospital roared overhead.

gettyimages 995049550 Entire Youth Soccer Team, Coach Rescued From Cave In Thailand

An ambulance leaves from the Tham Luang cave area as the operations continue for those still trapped inside the cave in Khun Nam Nang Non Forest Park in the Mae Sai district of Chiang Rai province on July 10, 2018. – Rescuers raced to save four young footballers and their coach who remain trapped in a flooded Thai cave on July 10, as heavy rains threatened an already perilous escape mission that has seen eight of the boys extracted in “good health”. (Photo by YE AUNG THU / AFP) (Photo credit should read YE AUNG THU/AFP/Getty Images)

Highlighting the dangers, a former Thai navy SEAL died Friday while replenishing oxygen canisters laid at regular intervals along the route out of the sprawling Tham Luang cave.

The plight of the boys and their coach has riveted Thailand and much of the world — from the heart-sinking news that they were missing to the first flickering video of the huddle of anxious yet smiling boys when they were found 10 days later by a pair of British divers. They were trapped in the cave that became flooded by monsoon rains while they were exploring it after a soccer practice on June 23.

The eight boys brought out by divers on Sunday and Monday were doing well and were in good spirits, a senior health official said Tuesday.

(Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.)