Twelve boys and their soccer coach who had been trapped in a cave in northern Thailand for more than two weeks have now all been extracted, rescuers announced Tuesday.

"I have good news to report. We brought five lives out safely," rescue operations commander Narongsak Osotthanakorn said at a news conference, referring to the last four boys and the coach.

Narongsak expressed gratitude to the rescuers for their work, which was carried out under intense scrutiny both from Thailand and the rest of the world. "Everybody is a real hero -- the rescuers, public and media," he said.

The Wild Boar soccer team members had entered the Tham Luang Nang Non cave, located in Chiang Rai Province, on June 23 and were subsequently trapped by rising flood waters.

Amid a frantic search effort by hundreds of rescuers and support personnel, foreign and Thai divers found the group sheltering on a dry patch about 4 kilometers from the entrance of the cave on July 2.

(Messages posted near the cave for the trapped soccer team)

Four boys were rescued Sunday, four more on Monday and the remaining four and the soccer coach on Tuesday. A doctor and three Thai navy SEALs who had been staying with them were also expected to be out within the day, rescue officials said earlier.

Water levels inside the flooded cave had remained stable since the extraction operation began Sunday, amid fears that flooding from heavy rain could trap those in the cave until the monsoon season ends months from now.

A former navy SEAL, 38-year-old Samarn Kunan, died last Thursday after falling unconscious while diving his way back from his mission to place air canisters along the exit route. Funeral services, typically lasting multiple days, are currently under way.

Congratulations on the successful rescue of the soccer team poured in from across the world.

British Prime Minister Theresa May said on Twitter that she was "delighted" at the news. "The world was watching and will be saluting the bravery of all those involved," she said.

Two divers from Britain found the boys on July 2 and its nationals accounted for more than half of the 13 foreign divers involved in their rescue.

U.S. President Donald Trump also extended his congratulations to the Thai navy SEALs and all others involved in the extraction, tweeting, "Such a beautiful moment - all freed, great job!

The U.S. Indo-Pacific Command sent 35 military personnel to help in the rescue effort.

(Tham Luang Nang Non cave complex on June 27)

In what could be a dream come true for the Thai soccer players and their coach, English soccer club Manchester United, which has a strong following in Thailand, invited them to its football stadium in England.

"We would love to welcome the team from Wild Boars Football Club and their rescuers to Old Trafford this coming season," the club tweeted.

Earlier, amid concern about the fate of those trapped in the cave, international soccer body FIFA invited them to the 2018 World Cup final, scheduled for this Sunday in Moscow, if extracted in time and their health allows them to travel.

However, Jedsada Chokdumrongsuk, permanent secretary at the Public Health Ministry, indicated Tuesday that will not be possible as they require at least a week of hospitalization.

Jedsada said the four boys rescued Sunday, aged 14 to 16, had lower-than-normal body temperatures and two of them exhibited symptoms of pneumonia, but their conditions have since improved with antibiotics and other treatment.

He said that of the four rescued Monday, aged 12 to 14, one had a slow heart rate but his condition has returned to normal.

Blood samples of all eight boys have been sent to Bangkok to see if they have any infections, the official said.

Psychologists are expected to evaluate the boys later.

Jedsada said the boys' parents are allowed to see them in hospital from behind a glass isolation barrier.

Another official told the same press conference that the boys, who had just been given easily digestible food, requested solid food such as bread with chocolate spread, and it was given to them.