The first group of boys was rescued on Sunday, the second group on Monday and the final five were brought to safety on Tuesday.
Here is what we know about the 12 boys from the Wild Boars soccer team and their 25-year-old coach.
- Chanin Viboonrungruang, 11, is the youngest member of the team. He began playing soccer when he was 7 years old. His nickname is Titan.
- Panumas Saengdee, 13, is big for his age, according to the head coach of the Wild Boars, Nopparat Kantawong. His nickname is Mig, and he told his parents in a letter that "the Navy Seals are taking good care of me."
- Duangphet Promthep, 13, is the Wild Boars captain. He is well-respected by his teammates, Nopparat told the BBC, and has been scouted by professional soccer clubs. His nickname is Dom.
- Somjai Jaiwong, 13, is described as a "cheerful boy" who loves sports. His goal is to become a star on the Thai national soccer team, one of his teachers told Agence France-Presse. His nickname is Pong.
- Mongkol Boonpiam, 13, is a "good boy" who loves school, according to his father. His nickname is Mark.
- Adul Sam-on, 14, is from Myanmar's Wa State. He moved to Thailand to get a better education according to the AFP story. Because he speaks four languages, he was the one who could communicate with the British divers who found the group nine days after they went missing.
- Natthawut Thakhamsai, 14, told his parents not to worry about him because he was alright. His parents told him they were waiting in front of the cave for him. His nickname is Tern.
- Akarat Wongsukchan, 14, promised his mother he would help her at the shop where she works once he was rescued. His nickname is Bew.
- Prajak Sutham, 15, is described as a smart and quiet boy. His nickname is Note.
- Pipat Phothi, 15, is the boy who wanted Thai barbeque when he got out of the cave. His nickname is Nick.
- Ponchai Kamluang, 16, tried to keep his parent's spirits up by writing a letter telling them, "Don't worry, I'm very happy." His nickname is Tee.
- Peerapat Somphiangjai, 17, it was Peerapat's birthday the group was celebrating when they went into the cave. His parents told him in a letter they would be holding his party after he was rescued. His nickname is Night.
- Assistant coach Ekapol Chanthawong, 25, was born in Myanmar and orphaned at an early age. He spent several years at a Buddhist monastery where he learned meditation. He taught the boys on the team how to meditate and conserve energy, according to The Australian. They were meditating when they were found, according to the British divers who found them nine days after they went missing. He has apologized to the boys' parents for taking them into the cave, and told them,"I promise I will take care of the kids as best as I can." His nickname is Ake.
Here is the timeline for what happened in the rescue watched around the world. For a look at live updates for the cave rescue, click here.
June 23: The boys and their coach go to the Tham Luang Nang Non cave to celebrate one of the team member's birthday. As they are exploring the cave, heavy rains begin and they become trapped. When none of the boys come home by evening, their parents begin to report them missing.
June 24: As the search begins, the boys' bicycles and other items are found near the cave entrance.
June 25: Authorities find more evidence that the boys likely went into the cave and became trapped. No one knows if they are alive.
June 26: The government brings in the Thai Navy SEALs to explore the cave, but find it difficult since water is filling the cave's chambers.
June 27: International cave diving experts are called on as more rain fills the caves. Pumps cannot keep up with the volume of water that needs to be pumped out.
June 28: Divers have to suspend the search because of water filling the cave. Teams begin drilling into the mountain to drain water.
June 29: Efforts to drain water from the caves is going slow because of more rain. Other options to try to find the team are explored. US and United Kingdom divers join the search.
June 30: Rescue efforts get a boost when the rains stop. More divers are able to go into the flooded caves and caverns to search for the team.
July 1: Navy SEALs reach the bend in the main passage of the cave and set up a staging area.
July 2: Ten days after the boys go into the cave, British cave divers find them. After they were found, the boys had a chance to send letters to their parents.
July 3: The world becomes more aware of what's happening in the cave as the video of the boys is released. Plans to get the boys out are considered, and people like SpaceX CEO Elon Musk offer their help.
July 4: Navy SEALs and a doctor get to the boys, bringing food and medicine. Officials ramp up efforts to pump the water out of the caves.
July 5: The SEALs begin to teach the boys how to dive. To get out of the caves the boys will have to walk where they can, but dive when they come to the portions of the escape route that are filled with water. None of the boys know how to dive. Some of them do not know how to swim.
July 6: While some have suggested that the boys stay in the caves until the monsoon season ends in Thailand several months from now, Thai officials say they want to get the boys out. On this day, a former Navy SEAL helping with the rescue dies from lack of oxygen.
July 7: The boys are still being trained in diving techniques. Officials announce the boys will be taken out of the cave using a buddy system with two divers for each boy. According to the Guardian, 40 Thai divers and 50 international divers with teams from the United States, Australia, the United Kingdom and China are part of the rescue attempt.
July 8: It's "D-Day" according to the Thai officials and the first four boys are safely brought out of the cave.
July 9: The second group of four boys is brought out. They are taken to the hospital where they join the first group of boys.
July 10: The last four boys and their coach are brought out of the cave, and the Thai Navy SEALs post on their Facebook page, "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 12 boys and coach Chanthawong will remain in the hospital for at least a week, Thai officials said.