In pictures: How the Thailand cave rescue unfolded
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.
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.
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.
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".
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".
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.
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.
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.
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.
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.
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.
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.
The operation is very complex, and involves a mixture of walking, wading, climbing and diving along guide ropes already in place.
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.
Efforts continue throughout Tuesday, until it is finally confirmed by officials that all 13 have been rescued safely.
Locals and rescuers at the site celebrate, as the last boys and their coach are transferred to hospital, 17 days after getting trapped underground.
All photographs copyright.