Last updated 4.45pm

All 12 boys and their soccer coach trapped for more than two weeks deep inside a flood Thai cave have been rescued, a Thai navy SEAL unit said on Tuesday, a successful end to a perilous mission that has gripped the world.

"The 12 Wild Boars and coach have emerged from the cave and they are safe," the Thai navy SEAL unit said on its official Facebook page.

At 4.30pm, it was confirmed that the medic and the divers had also successfully emerged from the cave.

The "Wild Boars" soccer team and their coach got trapped on June 23 while exploring the cave complex in the northern province of Chiang Rai after soccer practice and a rainy season downpour flooded the tunnels.

British divers found the 13, hungry and huddled in darkness on a muddy bank in a partly flooded chamber several kilometres inside the complex, on Monday last week.

After pondering for days how to get the 13 out, a rescue operation was launched on Sunday when four of the boys were brought out, tethered to rescue divers.

Another four were rescued on Monday and the last four boys and the coach were brought out on Tuesday.

Celebrations will be tinged with sadness over the loss of a former Thai navy diver who died last Friday while on a re-supply mission inside the cave in support of the rescue. 

A crack team of foreign divers and Thai Navy SEALS guided the boys out through nearly 4 km (2.5 miles) of sometimes submerged, pitch-dark channels.

Among them is Mikko Paasi, a diving instructor from Finland who was in Malta when the children were discovered in the cave and immediately flew to Thailand - on his wedding anniversary - to join the rescue effort. He had previously lived in Thailand.

Mr Paasi has since been into the cave several times and said on his facebook page this morning that conditions are still good He also uploaded pictures of his muddy diving suit and the divers working in cramped conditions.

The "Wild Boars" soccer team and their coach got trapped on June 23 when they set out to explore the vast cave complex after soccer practice, when a rainy season downpour flooded the tunnels. 

Sign up to our free newsletters

Get the best updates straight to your inbox:
Please select at least one mailing list.

You can unsubscribe at any time by clicking the link in the footer of our emails. We use Mailchimp as our marketing platform. By subscribing, you acknowledge that your information will be transferred to Mailchimp for processing.