For days Thailand anxiously followed every twist and turn of a dramatic race against time to find twelve boys and their football coach trapped deep in a cave complex and surrounded by rising monsoon floodwaters.

The search finally ended Monday, with dramatic footage showing the boys — exhausted, mud-caked and rake thin after nine days stranded — crammed onto a wedge of dry ground, some speaking faltering English with the British diving team that found them.

Now the focus shifts to the arduous task of extracting the group from the winding chambers and narrow passageways of the 10 kilometer (6 mile) long Tham Luang complex.

Rescuers said Tuesday they plan to supply the boys with up to four months’ food while a rescue can be planned, indicating the football team’s stay underground — and their families’ agonizing wait on the surface — may not be over just yet. 

From miners trapped underground, to sailors trapped underwater, here are some dramatic rescue operations that ended happily despite massive obstacles.

Gramat, France. 1999

On November 22, 1999, rescuers reached seven men who had been trapped in a cave system in southwest France for 10 days.

The men, all experienced cavers, became trapped in the caves at Vitarelles when heavy storms caused flooding, cutting them off from the exits.

The unprecedented rescue mission riveted France, with experts drilling multiple shafts into the rock in a bid to find the men.

They eventually reached them after squeezing into one of the shafts and following an underground river.

The men had carefully rationed their food and still had enough water and lighting gas for two days when they were rescued. All were in good health.

Kamchatka Peninsula, Russia. 2005

The seven-man crew of a Russian Priz mini-submarine were running out of air after three days trapped under water when they were finally rescued.

Their submarine became entangled in marine debris on August 4, 2005, and the Russian crew was powerless to move from the position around 190 meters (625 feet) below the ocean surface.

The incident immediately drew comparisons with Russia’s Kursk submarine accident five years earlier, which ended in tragedy with the deaths of all 118 crew.

But the Priz crew were rescued after a British undersea robot cut the vessel free.

Russian President Vladimir Putin awarded medals to the British team who rescued the submarine crew and Moscow announced it would purchase several of the type of underwater robots used in the rescue.

Copiapo, Chile. 2010

The plight of 33 men trapped in a Chilean mine 600 meters (2,000 feet) underground after a rock collapse on August 5, 2010 captured international headlines.

The men had been virtually given up for dead when a probe sent down through a narrow borehole struck lucky, 17 days later.

The men had been surviving on dwindling rations, with just 15 cans of tuna between them, said survivor Franklin Lobos.

“We ate a teaspoon of it every 24 hours, then every 48 hours and finally we were eating a teaspoon every 72 hours. It was horrible.”

Even after the men were located and supplies were sent to them, it took weeks before rescuers were finally able to bring the miners to the surface.

In all, their ordeal lasted nearly 70 days.

Ica, Peru. 2012

Nine miners, including a father and son, spent seven days trapped underground after a cave-in in southern Peru on April 7, 2012.

Rescuers led the men out wrapped in blankets and wearing dark glasses to protect their eyes after so many days without sunlight.

The rescue operation at the illegal mine was hampered by fears of additional collapses as rescuers dug through rock and soil.

Huddled in an opening 250 meters (800 feet) underground, the men joked and exercised to pass the time and stay positive.

“This moment, it’s like being reborn,” said one of the rescued men after a tearful reunion with his family.

Untersberg, Germany. 2014

More than 700 emergency personnel worked to rescue Johann Westhauser after he sustained a serious head injury deep inside a German cave system on June 8, 2014.

The 52-year-old was with two other people when a rockfall caused the head injury. One made the hours-long walk back to the surface to raise the alarm, while the other stayed with Westhauser.

His injury made it impossible for him to move, and rescue workers and medical professionals from five countries worked to medically evacuate him from a spot 1,000 meters (3,300 feet) below ground.

His rescuers battled dangerous conditions and near-freezing temperatures as they methodically negotiated a treacherous network of tunnels and chambers, underground lakes and ice-cold waterfalls.

He was eventually hauled out of the cave system on a stretcher 11 days after being injured, in an operation local officials said had seemed “simply impossible.”