MAE SAI, Thailand — Expert divers Sunday rescued four of 12 boys from a flooded cave in northern Thailand where they were trapped with their soccer coach for more than two weeks, as a dangerous and complicated operation unfolded amid heavy rain and the threat of rising water underground.

Eight boys and the coach remained inside the Tham Luang Nang Non cave as authorities paused the international effort to replenish air tanks along the treacherous exit route.

Extracting everyone could take up to four days, but the initial success raised hopes that could be done.

"The operation went much better than expected," said Chiang Rai acting Gov. Narongsak Osatanakorn, who is overseeing the mission.

He told reporters the four rescued boys were taken to the hospital in the town of Chiang Rai, the provincial capital, for evaluation, and the next phase of the operation will resume after about 10-20 hours.

The names of the rescued boys were not released.

His announcement, at a news conference more than an hour after helicopters and ambulances were seen rushing from the cave area, drew cheers and applause.

Narongsak had dubbed Sunday to be "D-day" as the complicated effort was launched in the morning.

He said 13 foreign divers and five Thai navy SEALs were taking part in the key leg of the rescue: taking the boys from where they have been sheltering and through dark, tight and twisting passageways filled with muddy water and strong currents.

Two divers were to accompany each of the boys, all of whom have been learning to dive only since July 2, when the first searchers found them.

Cave rescue experts consider an underwater escape to be a last resort, especially with people untrained in diving.

The death Friday of a former Thai navy SEAL, Saman Gunan, underscored the risks. The diver, the first fatality of the rescue effort, was working in a volunteer capacity and died on a mission to place oxygen canisters along the route.

But Narongsak said earlier that recent mild weather and falling water levels had created optimal conditions for an underwater evacuation. Those conditions won't last if the rain resumes, he said.

After the four boys were removed from the cave, heavy rain started falling.

The potential for rising water and the dwindling oxygen levels added to the urgency of getting the team out. Efforts to pump water out of the cave have been set back by heavy downpours.

Narongsak said Saturday that experts told him new rain could shrink the unflooded space where the boys are sheltering to just 10 square meters (108 square feet).

The next phase of the operation would start sometime Monday after rescue teams replenish the supply of oxygen tanks along the route.

On Sunday night, Thai navy SEALs posted a celebratory note on their Facebook page, saying: "Have sweet dreams everyone. Good night. Hooyah."

The boys and their coach, whose team is known as the Wild Boars, became stranded when they were exploring the cave after a practice game on June 23.

Monsoon flooding cut off their escape route and prevented rescuers from finding them for almost 10 days.

The ordeal has riveted Thailand and captured the world's attention. The search and rescue operation has involved dozens of international experts and rescuers, including a U.S. military team.

Elon Musk's Space X rocket company tested a "tiny kid-sized submarine" that could potentially help the children through the narrow, flooded cave passageways. A spokesman for Musk's Boring Co. tunneling unit, which has four engineers at the cave, said in an email Sunday that Thai officials had requested the device. If the tests were successful, the sub would be placed on a 17-hour flight to Thailand. He posted a video of a diver testing the device in a pool.

President Donald Trump tweeted Sunday: "The U.S. is working very closely with the Government of Thailand to help get all of the children out of the cave and to safety. Very brave and talented people!"

The boys sounded calm and reassuring in handwritten notes to their families that were made public Saturday. The notes were sent out with divers who made an 11-hour, back-and-forth journey.

One of the boys, identified as Tun, wrote: "Mom and Dad, please don't worry, I am fine. I've told Yod to get ready to take me out for fried chicken. With love."

"Don't be worried," wrote another boy, Mick. "I miss everyone. Grandpa, Uncle, Mom, Dad and siblings, I love you all. I'm happy being here inside, the navy SEALS have taken good care. Love you all."

One particularly touching note from another boy said: "I'm doing fine, but the air is a little cold, but don't worry. Although, don't forget to set up my birthday party."

In a letter of his own, coach Ekapol Chanthawong apologized to the boys' parents for the ordeal.

"To the parents of all the kids, right now the kids are all fine, the crew are taking good care. I promise I will care for the kids as best as possible. I want to say thanks for all the support and I want to apologize to the parents," he wrote.