Four of 12 Thai schoolboys who became stranded with their soccer coach more 16 days ago in a flooded cave were removed from the underground complex in northern Thailand on Sunday and rushed to hospital, officials said.

The area outside the Chiang Rai hospital, about 50 kilometres from the cave complex, was cordoned off by police. Down the street, vendors were told by loud speaker to "keep off the road" and to "not obstruct the transfer mission."

The operation to rescue the boys, ages 11-16, and their 25-year-old coach by having them dive out of the Tham Luang Nang Non cave began earlier in the day, with expert divers embarking on the complicated and dangerous mission.

Video provided by rescuers shows the first four boys being stretchered out of Tham Luang cave complex, where they had been trapped since Jun 23. Note that this video was provided without sound. 0:40

The first boy exited the cave at 5.40 p.m. local time. The second boy came out between 10 and 20 minutes after that, with the third and fourth boys leaving at 7.40 p.m. and 7.50 p.m. respectively, said Narongsak Osottanakorn, acting governor of Chiang Rai province.

"Today we managed to rescue and send back four children to Chiang Rai Prachanukrua Hospital safely," Narongsak told a news conference. "It's a big success of all teams. We have thousands of people helping us with the operation."

The healthiest were taken out first, officials told reporters.

The governor, who is heading the operation, said about 90 divers — including 50 foreigners and 40 Thais — were involved in Sunday's recovery, which went "better than expected."

Some divers escorted the boys, while others were positioned along the dangerous first kilometre stretch, where the boys had to navigate through submerged passageways in some places no more than 60 centimetres wide.

One of two ambulances leaves the cave in northern Thailand hours after operation began to rescue the trapped youth soccer players and their coach, in Mae Sai, Chiang Rai province, in northern Thailand, on Sunday. (Sakchai Lalit/Associated Press)

Osottanakorn said the next phase of the operation was expected to start Monday morning Thailand time at the earliest. It's an 11-hour back-and-forth journey for the divers, who will need to rest, while the rescue team replaces air canisters along the route.

Helicopters and several ambulances were seen departing from the cave area, though there was no official announcement of whom they were carrying.

A rescuer arrives outside the Tham Luang cave complex in the northern province of Chiang Rai, Thailand, on Sunday. (Tyrone Siu/Reuters)

Narongsak said earlier that two divers would accompany each boy as they're gradually extracted. The operation began at 10 a.m. local time. "Today is D-Day," Narongsak told reporters.

An Australian doctor checked the health of the boys on Saturday night and gave the all-clear for the operation to proceed.

The entire operation to rescue all 13 could last two to four days, depending on weather and water conditions, said army Maj. Gen. Chalongchai Chaiyakam.

The Thai governor leading the rescue operation to free 12 boys and their soccer coach from a flooded cave says Sunday's effort was the "best situation." 0:17

​The boys and their coach became trapped when they went exploring in the cave after a practice game June 23. Monsoon flooding cut off their escape and prevented rescuers from finding them for almost 10 days.

The only way to bring them out of the cave is by navigating dark and tight passageways filled with muddy water and strong currents, as well as oxygen-depleted air. A former Thai navy SEAL died while making the four-kilometre journey on Friday.

Local people wait on Sunday in front of the Chiang Rai hospital where the boys are expected to get treatment once rescued. (Soe Zeya Tun/Reuters)

Experienced cave rescue experts consider an underwater escape risky, especially with people untrained in diving, as the boys are. The path out is considered especially complicated because of twists and turns in narrow flooded passages.

But the governor supervising the mission said earlier that mild weather and falling water levels over the last few days had created optimal conditions for an underwater evacuation that won't last if it rains again.

A truck carrying oxygen tanks arrives outside the Tham Luang cave complex. (Tyrone Siu/Reuters)

Before announcing that the rescue was underway, authorities ordered the throngs of media that have gathered at the cave from around the world to leave.

'We are at war with water'

Authorities had said that incoming monsoon rains that could send water levels in the cave rising, coupled with falling oxygen levels in the enclosed space, added to the urgency of getting those trapped out. Earlier efforts to pump out water from the cave have been set back every time there has been a heavy downpour.

"It's been raining more every day," freelance journalist Stephen Boitano told CBC News. He said a torrential downpour lasting half an hour hit as the rescue operation got underway.

A relative shows a transcript of a message from a boy nicknamed Adun, one of the 12 schoolboys who were trapped in a flooded cave. (Soe Zeya Tun/Reuters)

Narongsak said on Saturday that experts told him water from new rain could shrink the unflooded space where the boys are sheltering to just 10 square metres.

"I confirm that we are at war with water and time from the first day up to today," he said Saturday. "Finding the boys doesn't mean we've finished our mission. It is only a small battle we've won, but the war has not ended. The war ends when we win all three battles — the battles to search, rescue and send them home."

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 to act as postmen.

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, 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," wrote Mick.

"Night loves Dad and Mom and brother, don't worry about me. Night loves you all," wrote Night, in the Thai manner of referring to one's self in the third person.

One of the most touching notes came from a boy whose name was not clear: "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."

Another, of indistinct origin, asked their teacher not to give them a lot of homework.

The boys stranded in the cave will be dealing with several challenges as they swim through pitch-black, treacherous tunnels to escape. 5:29

In a letter of his own, the 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.

An update Saturday from the Thai navy said three navy SEALs were with the boys and their coach, one a doctor. The 13 were having health evaluations and rehabilitation, and were being taught diving skills. Food, electrolyte drinks, drinking water, medicine and oxygen canisters have been delivered to them. A major concern of the rescuers is that oxygen levels in their safe space could fall dangerously low.

Rescuers have been unable to extend a hose pumping oxygen all the way to where the boys are, but have brought them some compressed air tanks.

'Very dangerous undertaking'

Doug Munroe, an experienced cave rescuer with the Alberta/B.C. Cave Rescue Service, said the rescuers will have to guard against fatigue as they concentrate at the task at hand, navigating through a cave complex where some passages are only "two feet across and one feet tall, maybe less."

"When you are in a rescue situation, you often tend to forget about yourself. In my experience, you become very focused on the task at hand, and that's one of the things that can create risks to rescuers. They may not attend to their own safety as much as they would otherwise attend," Munroe told CBC News.

"This is certainly a very dangerous undertaking," said Christian Chenier, who teaches cave rescue in Quebec.

Prime minister criticized

Prime Minister Prayuth Chan-ocha, leader of the military junta that seized power in 2014, planned to visit the cave site on Monday, a government spokesman said.

His visit with relatives and rescue officials last week was criticized by some Thais as opportunistic, as his government faced pro-democracy protests in the capital Bangkok in recent months.

The California tunnel company run by Elon Musk is continuing to maintain a presence at the cave.

Sam Teller, spokesman for Boring Co., said Sunday that the company has four engineers who are "offering support in any way the government deems useful."

Musk tweeted early Saturday that he was working with a team from his Space X rocket company to build a "tiny kid-size submarine" to transport the children.

But Saturday night, he tweeted that the cave was now closed for the rescue by divers.

"Will continue testing in L.A. in case needed later or somewhere else in the future," he wrote.