A fire that broke out in the dormitory of a boarding school killed at least 17 young girls in northern Chiang Rai province.
Five other girls were being treated for injuries, with two of them in a serious condition.
The blaze in Wiang Pa Pao district started at about 11pm on Sunday and took about an hour to bring under control, said local officials.
"It happened late at night, so they were already asleep when the fire broke out. The door and staircase were also burnt, so it was not easy for them to escape," district chief Prasert Jitplercheep told The Straits Times. "Those who survived were rescued by firefighters, who climbed up using ladders."
The victims were aged between five and 12 years.
Forensic experts said a faulty fluorescent light may have sparked the fire. A hot fragment from the light fell onto a pile of clothes in a ground-floor room right below where the children were sleeping, senior forensic police officer Sant Sukhavachana was quoted by Reuters as saying. The clothes soon caught fire and the flames spread swiftly.
A boarder, 12-year-old Kwanjira Ananthaphet, said she tried to alert the other girls after she smelled smoke. Most of them were sound asleep and some did not believe her, reported The Nation.
Kwanjira said she and some girls climbed down a nylon rope from a first-floor window. Others escaped using a rope that a teacher had made from bedsheets, the girl was quoted as saying.
The death toll could have been higher if all 38 girls who lived in the dormitory were present. Two were away that night, said Mr Prasert.
Mr Rewat Wassana, who manages the Christian school, told the Khaosod English online newspaper that most of the pupils came from poor families and that their education was sponsored by the school's foundation. Some were from the minority Hmong ethnic group.
Chiang Rai and its remote hilly surrounds are home to many of Thailand's ethnic minority groups, where access to education remains a challenge.
Television reports showed the charred remains of the two-storey building, its roof collapsed and interior reduced to rubble.
According to the school's Facebook page, it will remain closed until Friday.