CNN  — 

Medics who treated the 12 boys and their soccer coach rescued from a cave in Thailand last year credit the drug ketamine with playing a key role in the daring and dangerous mission to extract them.

According to details of the rescue released in a medical journal Thursday, the boys were given unspecified doses of ketamine, also known as party drug Special K, by the rescue divers as they were taken out of Tham Luang cave.

Reports at the time had suggested that the children, who had been trapped for two weeks, were sedated during the operation, but officials gave few details.

“We had to use the means that could keep the children not to be panicky while we were carrying them out,” Thai Navy SEAL commander Rear Adm. Arpakorn Yookongkaew told CNN shortly after the rescue. “Most importantly, they are alive and safe.”

In a joint letter to the New England Journal of Medicine, three Thai medics and an Australian anesthetist who was involved in the rescue said the boys also wore full-face masks supplying oxygen and poorly fitting wetsuits.

They detailed the care the boys received in a field hospital immediately after they left the cave, giving a sense of the perilous nature of the rescue mission.

The first four boys were given sunglasses to protect their eyes because they had not been exposed to the sun for more than two weeks, and their heads and necks immobilized in case of spinal injury during the journey through the narrow channels in the cave. Finally, the patients were wrapped in blankets to ward off hypothermia.

The letter said the second boy to leave the cave had a body temperature of 35 degrees Celsius (95 Fahrenheit) when he came out and developed hypothermia on his way to the hospital. Hypothermia can cause damage to vital organs, including the heart and kidneys, and the nervous system.

The medics said ketamine was a good choice to give to the boys, given the risk of hypothermia, as ketamine impairs shivering and is associated with smaller drops in core body temperature.

Ketamine was first synthesized in 1962 and was used by US Army doctors on American soldiers fighting in Vietnam as a painkiller and sedative. However, its minor hallucinogenic side effects warned doctors off treating people, and it developed a reputation as a street drug known for producing a high similar to an out-of-body experience. It has also been used as a date rape drug.

Today, ketamine is used in pediatric emergency rooms, for example in the case of a fracture, because it’s safer than other sedatives, said CNN’s Dr. Edith Bracho-Sanchez, a pediatrician.

It is also used is as a veterinary anesthetic and a close cousin of the drug was recently approved as a treatment for depression. The drug is on the World Health Organization’s Essential Medicine List for adults.

The soccer team entered the cave after going for a bike ride, only to be trapped by rising floodwaters on June 23. The boys and their coach were found alive more than a week later, deep in the cave network and hundreds of meters below the surface.

It was clear that any rescue mission would be fraught with risk. Divers involved in the rescue described the conditions as some of the most extreme they have ever faced.

Get CNN Health's weekly newsletter

Sign up here to get The Results Are In with Dr. Sanjay Gupta every Tuesday from the CNN Health team.

The decision to rescue the boys was complicated by the death of former Thai Navy SEAL Saman Kunan, who ran out of air while returning from an operation to deliver oxygen tanks to the cave.

Richard Harris, the Australian anesthesiologist, was one of only two cave-diving anesthesiologists in the world.

“I didn’t think it would work at all,” Harris told National Geographic. “I expected the first two kids to drown and then we’d have to do something different. I put their odds of survival at zero.”