Thailand gave diplomatic immunity to three Australians who helped a boys' soccer team escape from a flooded cave, in case "something went wrong", its foreign minister said on Monday.
The 12 boys of the "Wild Boars" soccer team and their coach are recovering from their ordeal and are to be discharged on Thursday from a hospital in the northern town of Chiang Rai.
Dozens of foreign divers and rescue personnel joined the 17-day rescue that captivated people around the world.
But immunity was granted only to Australian doctor Richard Harris and two medical assistants, said Foreign Minister Don Pramudwinai.
"Doctor Richard Harris did his utmost on the medical mission he was responsible for, but if something went wrong he needed protection," he told Reuters.
"We provided this only to Dr. Richard Harris and two medical assistants. Only to the Australian medical team," he said.
"We knew there were risks involved in this mission...so there was an understanding reached between the Thai government and the Australian government," Don added.
"The Thai government would like to thank Dr. Harris."
A spokeswoman for Australia's Department of Foreign Affairs and Trade declined to comment.
The success was tinged with bitterness, however, as Harris learnt his father, Jim, died in Australia shortly after the three-day rescue was completed last week.
Harris, an anaesthetist, went into the Tham Luang cave to assess the boys' health and was one of the last rescuers out of the cave after the boys, aged 11 to 16, and their 25-year-old coach were brought to safety.
There have been reports the boys were sedated for their trip out through narrow, flooded passageways, though officials said only that some had been given medicine to calm their nerves.
The soccer team was exploring the cave on June 23 when monsoon rains trapped them deep inside the 10-km (6-mile mile) cave complex.
Thai navy SEALs and an international team of cave-diving experts played a key role in bringing them to safety.
Thais have flooded social media with grateful messages for mission participants, including Harris and the only casualty, Samarn Kunan, 38, a former member of Thailand's elite SEALs unit.
Samarn, who died after delivering oxygen tanks in the cave, was cremated on Saturday in a ceremony broadcast live on Thai television.
The boys wiped away tears as they signed a portrait of Samarn, in photographs released by the hospital on Sunday.