The 12 boys, all part of a youth soccer team known as the Wild Boars, first went missing with their coach more than two weeks ago.
The youngsters and their coach got trapped on June 23 while exploring the cave in the northern province of Chiang Rai after soccer practice, when a rainy season downpour flooded the tunnels.
Its Twitter post read: "The best football news of the summer - ALL 12 young Thai players and their coach have been rescued after being trapped in a cave in Thailand for two weeks". Tuesday's evacuation operation involved more than 100 people.
Three members of the SEAL unit and an army doctor, who has stayed with the boys since they were found, were the last people due to come out of the cave, the unit said. The operation included stashing tanks of air on the long route to safety, a process that took hours to set up between rescue missions.
"Water levels are the same like the last two days", he said, adding that rescue efforts were expected to faster than they had been before.
The eight boys who have left the cave are being treated in an isolation ward in a Chiang Rai hospital.
It could be at least seven days before they can be released from hospital, Jesada said.
The most recent boys to have been rescued have been stretchered out of the cave system, amid fears that they could have contracted a nasty illness. The eight boys brought out by divers over the previous two days were doing well and were in good spirits, a senior health official said.
On the first two days of the unsafe escape bid, eight fearless children were rescued from the living nightmare after swimming through muddy water chaperoned by two adult guides.
Today, the four remaining boys were confirmed to have been rescued and were taken to hospital after Reuters reported that those in charge of the rescue mission were "hopeful" all 12 boys plus the coach would be out today.
Musk has offered a "kid-sized" submarine, named Wild Boar after the kids' soccer team, to help in the rescue operation.
They were originally stuck after taking shelter from monsoon rains inside the caves, and walked further in to escape flooding. Before the final rescue, he told CNN that divers inside the cave faced a number of challenges.
The tech entrepreneur tweeted Tuesday morning he'd "Just returned from Cave 3" referring to the rescuers' command centre inside the extensive cave network. Jedsada said they were uncertain what type of infections the boys could face, "because we have never experienced this kind of issue from a deep cave".