The Thai cave complex where 12 boys and their football coach became trapped is a snaking system of caverns and crevices which posed a range of problems for rescuers.

Some stretches of the Tham Luang cave are more than 10m (33ft) high, while others are a tight squeeze through water-filled passages.

The death of an experienced former Thai navy diver, who was part of a team trying to supply the boys' cave with oxygen tanks, emphasised the dangers of the mission.

The group of boys and their coach were exploring the caves when a sudden storm caused the passageways to flood, trapping them inside. They had spent nine days in the cave with little food or light when they were discovered on Monday 2 July.

Image copyright AFP/Royal Thai Navy

Rescuers initially wanted to keep the group supplied underground until the end of the rainy season - which would have taken months.

But with the forecast of heavy rains, and the risk of water levels rising, an operation was launched on Sunday, 8 July, to bring them out.

How did the boys escape?

Rescue divers with specialist breathing equipment reached the group through a series of water-filled passages.

The boys had to be brought out the same way.

Sources in the rescue operation, including divers who took part, told the BBC that the boys were heavily sedated ahead of the rescue to prevent them panicking in the dark, tight, underwater passageways.

The boys were fitted with full-face breathing masks. For the underwater sections, they were strapped to a rescue diver. The divers were guided through the dark by dive lines.

British rescuer John Volanthen, one of those who first discovered the boys, said divers were able to practice rescue techniques with Thai boys from a local swimming club in a pool.

"We strapped a cylinder to the front of the child and they had a full-face mask… and essentially we had a handle on the back of the child," he said

The divers were then able to manoeuvre the boys face down along the passageways.

"If you want a picture, it was probably more like a shopping bag that sometimes you would hold close to your chest if the passage was narrow and deep. If the passage was low and wide you would hold them out to the side and essentially manoeuvre them around any obstacles that were in the way," he said.

The boys were clipped to the divers for safety in case they lost sight of them in the murky water.

Initial reports suggested each boy was to have two rescue divers - one holding them and one swimming behind - but rescuer Rick Stanton said in the end it was one on one.

"We didn't have the personnel to do two on one," he told ITV This Morning.

The diving option was considered extremely dangerous by some, but dive experts said the priority was to get the boys out before the rains brought more flooding and debris into the cave system.

About 40% of the boys' journey through the water involved diving and in other parts the water was up to the rescuers' chests, Thai Navy SEAL commander Rear Admiral Apakorn Yuukongkaew told reporters.

After the flooded section, when they reached the divers' operating base the cave, the boys were bundled into stretchers and carried or winched along ropes, according to footage released by the Thai Navy Seals.

Image copyright AFP/Royal Thai Navy

Each journey back to the entrance took several hours.

The rescue mission started on 8 July, with divers entering the cave at 10:00 local time (03:00 GMT). The first boy emerged at 17:40 and by 19:47, three more had followed.

The mission was paused overnight for air tanks to be replaced along the route but resumed again on Monday and Tuesday until the remaining boys and their coach were brought out and transferred to hospital.

Waiting and pumping

There was a round-the-clock pumping operation to try to clear the caves.

But as fast as the water was being pumped out, more was flowing in, fed by sinkholes and streams in the hills above, and the risks from the imminent monsoon rains was high.

Mr Narongsak said the mission had been "a race against the water".

Image copyright Getty Images

Drilling down

The authorities did try to drill holes in the cave walls to help drain some of the flood water - although the thick rock hampered efforts.

There were also suggestions that drilling could be another way to get to the boys and lift them out.

But to even begin the process, new roads would have been needed to be built up above the caves to accommodate the heavy drilling equipment needed to break through the rock.

Image copyright EPA Image caption Authorities have tried to drill holes to let out flood waters

A detailed survey of the area would also have had to be done - otherwise there would be little chance of digging a hole in the right place to reach the boys and their coach. Drilling could also destabilise rocks above the children or block passages and increase flooding.

What were the dangers down there?

The boys, aged between 11 and 17, and their 25-year-old coach had been huddled on a small rock ledge. The environment was wet, so they had to keep warm and dry or risk hypothermia.

There were concerns about the level of oxygen in the air in the space where the boys were trapped. Officials said at one point that the level of oxygen in the air had fallen to 15%. The usual level is 21%.

Rescuers transferred about 100 oxygen tanks to the cave to help improve the air supply.

Thai diver PO Saman had been helping transfer the tanks when he got into difficulties on the way back and did not have enough air himself. He died after losing consciousness in one of the passageways and his colleagues could not revive him.

Media playback is unsupported on your device Media caption Diver Ben Reymenants is aiding the rescue mission and says none of the boys can swim

Read more:

What help did they receive?

Much-needed food and medical supplies, including fresh water and paracetamol, reached the boys and their coach on Tuesday. Rescuers transferred supplies to the boys to build up their energy and nutrient levels.

Rear Admiral Arpakorn Yuukongkaew, head of the Thai navy's special forces, told reporters they were given "easy-to-digest, high-energy food with vitamins and minerals, under the supervision of a doctor".

Officials said most of the group were unhurt, although some were weak or had minor injuries.

Image caption A camp of rescuers, volunteers, relatives and the press built up outside the cave entrance

How did they deal with the mental strain?

The boys had to restrict the use of torches they had with them. Rescue teams took lighting into the chamber and kept the group company as they waited for the rescue operation to begin.

Divers also brought letters from the boy's parents to help them handle the strain, and one of the Navy Seals played chess with them to pass the time.

Image copyright Facebook/ekatol Image caption A Facebook photo shows the coach with some of the young footballers

"Luckily the coach had the sanity of mind to keep them all together, huddled together to conserve their energy, that basically saved them," Ben Reymenants, a Belgian diver who helped with the rescue operation, told AFP news agency.

In a press conference after the boys were released from hospital, the boys thanked their rescuers. They paid tribute to the diver who died and said they would say sorry to their parents for going to the cave after telling them they were going to football practice.