Updated

The dramatic three-day rescue of a Thai youth soccer team that had been stuck in a flooded cave came to an end Tuesday when the last boy and the team's coach were plucked from the underground cavern -- more than two weeks after they became trapped, Navy officials said.

The Thai Navy SEALS said on Facebook all 12 boys from the team and the team's coach were out of the cave. Four rescuers, a doctor and three Navy SEALS remained inside until coming out of the cave two hours later.

"All 12 Wild Boars and coach have been extracted from the cave. Hooyah!" the post said. The Navy SEALS later wrote: "We are not sure if this is a miracle, a science, or what. All the thirteen Wild Boars are now out of the cave."

Earlier in the day, local Thai media reports stated the 11th person emerged from the cave after two other people had been rescued. The conditions of all of those who were saved on Tuesday were unclear.

Chiang Rai Gov. Narongsak Osatanakorn said Tuesday's intricate and high-risk operation began just after 10 a.m. and involved 19 divers.

"We did something nobody thought possible," he said during a brief news conference after the rescue was complete.

Cave Search Thai 2

This photo tweeted by Elon Musk shows efforts underway to rescue trapped members of a youth soccer team from a flooded cave in northern Thailand. (Courtesy of Elon Musk via AP)

Cheers and applause were reported in the streets as the final ambulance arrived at a hospital in Chiang Rai city. Payap Maiming, 40, who helped provide food and necessities to rescue workers and journalists, told the Associated Press a "miracle" had happened.

"I'm happy for Thais all over the country, for the people of Mae Sai, and actually just everyone in the world because every news channel has presented this story and this is what we have been waiting for," she said. Mae Sai is the district where the cave is located, in the northern part of Chiang Rai province, near the border with Myanmar.

"It's really a miracle," Payap said. "It's hope and faith that has brought us this success."

Before the final rescue of the group, there was optimism that the dive team was getting more efficient in their attempts. They successfully extracted the second group of four a full two hours faster than the first, officials said.

THAI CAVE RESCUE TIMELINE: THE DANGEROUS RACE TO BRING TRAPPED SOCCER TEAM HOME

"Two days, eight Boars," read an earlier Facebook post by the Thai navy SEALS about the operation at the Tham Luan Nang Non cave that began Sunday, more than two weeks after the Wild Boars soccer team became trapped.

SpaceX and Tesla head Elon Musk, who visited the cave, released photos of the situation on Twitter, and said his high-tech submarine was ready to help if needed.

"Just returned from Cave 3. Mini-sub is ready if needed," Musk tweeted. "It is made of rocket parts & named Wild Boar after kids’ soccer team. Leaving here in case it may be useful in the future. Thailand is so beautiful."

But despite his offer to help, the Thai rescue chief said it would be of little use for the rescue of the boys, according to Sky News.

"Although his technology is good and sophisticated it’s not practical for this mission,” Narongsak said.

The divers began the third phase of the operation at 10 a.m. Tuseday local time to bring the remaining boys and their 25-year-old coach out of the Tham Luang Nang Non cave in Chiang Rai province.

The boy's families were being kept at a distance at a hospital because of fears of infection and the emaciated-looking boys were eating a rice-based porridge because they were still too weak to take regular food, authorities said.

Rescue operations have required two divers to go out with each boy through the cave.

At a news conference on Tuesday morning, officials said the second group of four boys brought out Monday are healthy, and that there are no bats inside the cave so there are no animals that can transit any diseases.

Jesada Chokdumrongsuk, deputy director-general of the Public Health Ministry, said Tuesday that the first four boys rescued, aged 12 to 16, are now able to eat normal food. He added that two of them possibly have a lung infection but all eight are generally "healthy and smiling," and "the kids are footballers so they have high immune systems."

The second group of four rescued on Monday are aged 12 to 14, and all are in "high spirits," he added.

Doctors are expecting to keep the boys in the hospital for at least 7 days, and said there are no complications with the boy's eyesight despite spending multiple days in the dark.

The parents of the first group of boys rescued on Sunday have visited their children through glass windows, as doctors continue to keep them "isolated" as they ensure they are healthy. The group has been vaccinated and given vitamin B1 and IV drips, according to officials.

THAILAND CAVE RESCUE OPERATION: 4 MORE BOYS FREED, BRINGING TOTAL TO 8

Throughout the daring rescue, there was the risk of monsoon rains rising water in the cave endangering the team's dry refuge and making the escape route too treacherous.

ThaiTeam2

A Thai well wisher puts a poster to pray for boys and their soccer coach. (AP Photo/Sakchai Lalit)

The plight of the boys, aged 11-16, and their coach, has riveted Thailand and much of the world -- from the heart-sinking news they were missing to the first flickering video of the huddle of anxious yet smiling boys once they were found by the pair of British divers deep in the sprawling cave.

President Trump congratulated the Thai navy SEALs and their international partners who rescued the team and their coach after more than two weeks of entrapment in a cave.

"On behalf of the United States, congratulations to the Thai Navy SEALs and all on the successful rescue of the 12 boys and their coach from the treacherous cave in Thailand," he wrote on Twitter. "Such a beautiful moment - all freed, great job!"

Writing in elegant Thai script, the boys urged their parents not to worry, adding that they hoped they wouldn't get too much homework after being rescued and couldn't wait to eat their favorite foods again.

Thailand's prime minister said Tuesday that increased security will be introduced at the cave made "world famous" by this week's heroic rescue operation, Sky News reported.

Cave Search Thai 1

Rescuers walk toward the entrance to a cave complex where five were still trapped, in Mae Sai, Chiang Rai province, northern Thailand Tuesday, July 10, 2018. (AP Photo/Sakchai Lalit)

"In future, we have to monitor the entrance and exit to the cave. This cave has become world famous," Prime Minister Prayuth Chan-ocha said. "We have to install more lights inside the cave and put up signs. It's a dangerous cave."

All preparations of the rescue, including replacing the oxygen cylinders positioned along the route out in the cave, take at least 20 hours, officials said. The safety of the divers, who have meticulously planned the mission, is also paramount. One diver died during preparations for the boys' extraction.

Fox News' Jeff Paul and Melissa Chrise in Chiang Rai, Thailand, and The Associated Press contributed to this report