All 12 boys and their football coach have been rescued from a flooded cave in Thailand, ending an 18-day ordeal that riveted people around the world.

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 hospital roared overhead.

Thai navy 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 on 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’ football team.

People wait as police block the road during an emergency helicopter evacuation in Chiang Rai (Vincent Thian/AP)

“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.

Seven divers in the rescue team were from the UK, including Rick Stanton and John Volanthen, who were the first to reach the group last week.

(PA Graphics)

The plight of the boys and their coach made headlines across the globe – from the heartbreaking 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 the British divers.

One of the boys appeared to be wearing a red replica England football shirt.

They were trapped in the cave that became flooded by monsoon rains while they were exploring it after football practice on June 23.

On behalf of the United States, congratulations to the Thai Navy SEALs and all on the successful rescue of the 12 boys and their coach from the treacherous cave in Thailand. Such a beautiful moment - all freed, great job!