In pictures: How the Thailand cave rescue unfolded

Getty Images An onlooker clasps her hands as she cheers on ambulance taking the childrenGetty Images
The successful 17-day search and rescue operation has captivated the country

The desperate effort to find and rescue a team of young footballers in Thailand from a flooded cave has gripped the world. After the last boys and their coach were rescued on Tuesday, we look back at how the story unfolded.

On Saturday 23 June, 12 members of the Wild Boar soccer team, aged 11-16, entered the Tham Luang cave system in Thailand's Chiang Rai Province along with their 25-year-old football coach after a team practice.

The cave system, which is 10km (6 miles) deep, is known locally for its deep recesses and narrow passages. The team has reportedly visited the cave before - but this time heavy rains cause flooding, impeding their exit.

After the children fail to return home, they are reported missing and search efforts begin.

Initial rescuers at the site reportedly find the team's bicycles, football boots and other belongings close to the cave's entrance.

AFP/Getty Bicycles pictured close to the cave's entranceAFP/Getty
BBC Presentational white space
EPA People gather in the cave system for a briefing, with special lighting equipment brought inEPA

Media and volunteers start to gather at the site as heavy rain continues to complicate the search and rescue process.

By Sunday family members reach the cave, praying and holding vigils for the missing children.

Getty Images A woman is pictured praying in waterproof hood outside of siteGetty Images

Three days in, divers from the Royal Thai Navy arrive to assist in local search efforts.

Fresh hand and footprints are spotted inside the vast cave complex, raising hopes for the group's safety.

Government officials visit the site, and Deputy Prime Minister Prawit Wongsuwon says the government is still optimistic the team can be found alive.

Rescuers consider other routes in - teams of soldiers search for alternative entrance points and the authorities consider drilling into the mountain to get access.

AFP/Getty Rescue personnel carrying diving tanks on their backs gather at the cave siteAFP/Getty
BBC Presentational white space
AFP/Getty Soldiers relaying electric cables into the cave systemAFP/Getty

By Wednesday 27 June, diving and survival specialists from all around the world arrive in the country to help with search efforts.

Relatives continue to hold vigils and pray at the site, as concern about the under-16 team's fate grows. Family members and officers are pictured fainting, and desperation deepens as weather conditions deteriorate.

Thailand is now captivated by the desperate search, clinging to hope they can survive. Social media users share fan art in tribute to the missing 13, referring to them as "the strangers we want to meet the most".

Twitter/@namwoon_ccw Cartoon showing the boys hugging rescuersTwitter/@namwoon_ccw

Pumps are brought in to try to help reduce the water levels in the cave, but continuing rain intermittently suspends efforts.

Rescuers now believe and hope the team sought safety on a rock mound inside a cave chamber known as "Patayya beach".

Reuters A relative is pictured looking down in a sad manner, in a close-up imageReuters
BBC Presentational white space
Reuters The prime minister holds microphone for relative as he listens to her at an eventReuters

Prime Minister Prayuth Chan-ocha visits relatives at the site and tries to offer comfort, telling them: "They're athletes. They're strong."

The world's media has by now gathered at the site, with journalists staking out in the muddy conditions to hear the latest news.

Getty Images Dozens of media cameras are pictured, covered with makeshift waterproof protectionGetty Images

Over the weekend of 30 June, a break in rainy conditions allows divers to get further inside the cave than before.

Supplies and air tanks are brought into the cave as the rescue teams advance.

AFP/Getty Technicians lifting water pumps at drilling site near the cave systemAFP/Getty

On Monday 2 July there is dramatic news - divers have found all of the boys and their coach safe nine days after they went missing.

The team are found on a rock shelf about 4km (2.5 miles) from the cave mouth.

Royal Thai Navy Still from video showing the boys perchedRoyal Thai Navy
A video is released of the moment they are discovered by British divers
BBC Presentational white space
AFP/Getty Family members celebrating and looking emotional, as tv cameras film their reaction.AFP/Getty
There are scenes of joy and relief at the site, as relatives and officials celebrate the news

A video showing the boys in apparent good health is released by the Thai Navy seals, but officials stress that the rescue effort remains complex.

Medical aid and food is brought in to the team, as rescuers consider the best way to get them out to safety.

Millions of litres of water are being pumped out of the cave system, but with the rainy season in full flow, officials warn the boys may have to learn to dive to get free - or wait months until conditions approve.

Getty Images Bulldozer and other heavy equipment pictured at top of cave siteGetty Images
BBC Presentational white space
Getty Images Oxygen tanks pictured outside the siteGetty Images

The buoyant mood at the site then sours dramatically at the end of the week after a diver working on the rescue dies.

It emerges that Saman Gunan, 38, a former Thai navy diver volunteering in the cave, lost consciousness while delivering oxygen air tanks.

Reuters Saman Gunan's coffin is carried by soldiersReuters

Tributes pour in for the lost diver, as concern is raised about the difficult task ahead.

The commander of Thailand's Navy Seals warns that oxygen levels are dropping, as notes written by the team and coach emerge and are released.

Getty Images A note written in ThaiGetty Images
In one, the youngsters urge relatives to not worry, saying they are strong

In a race against the rain, officials designate a "limited" window during which they believe the team can be successfully evacuated out.

With conditions optimum on Sunday 8 July, "D-Day" comes and intensive rescue operations begin.

Ambulances are pictured leaving the site, as speculation grows about how the rescue went. It is eventually confirmed that four of the boys have been safely brought out.

Officials say the operation is running "smoothly", but efforts pause overnight to replace air tanks and let divers rest.

Reuters An ambulance with sirens on speeds away from the scene where children were rescuedReuters
Ambulances leaving the site are monitored closely by the watching media

The operation is very complex, and involves a mixture of walking, wading, climbing and diving along guide ropes already in place.

Getty Images Nurses pictured outside of Chiangrai Prachanukroh Hospital,Getty Images
Those evacuated out are being cared for in local hospitals, gradually being weaned back onto solid foods
Reuters Children smile after being told the news of some of the children's rescuesReuters
Classmates are pictured celebrating the news of the ongoing rescues

The government strictly guards information about the rescue, including the names of those who have been saved.

The boys are held in hospital for supervision. Access for visiting parents is said to be limited because of potential health risks.

On Tuesday there are high hopes for a successful rescue of everyone, as a final push starts to free those still inside.

Reuters Onlookers wave at ambulance going byReuters
Locals pictured waving at ambulances driving out of the nerve-wracked rescue site

Locals and rescuers at the site celebrate, as the last boys and their coach are transferred to hospital, 17 days after getting trapped underground.

Getty Images A man is pictured watching the news of the boys' rescue on a television in nearby Chiang RaiGetty Images
People living locally are pictured celebrating and watching the news on television
BBC Presentational white space
Getty Images A girl wearing a hat with Wild Boar symbolGetty Images
One young girl wears the symbol of the Wild Boar team, which has now become well-known

All photographs copyright.