The fire started late Sunday night, meaning many of the children at the school run by a Christian charity were asleep as flames spread through the two-storey wooden building.
‘The fire broke out at 11 pm on Sunday (1600 GMT). Seventeen girls were killed, with five injured,’ Colonel Prayad Singsin of the police in the town of Chiang Rai told AFP.
Two of the injured are in a serious condition, he said, but initial fears that two more girls were missing had been discounted after rescuers picked through the charred debris.
The school in Wiang Pa Pao disttrict is home to girls aged between six and 13.
Those in the dormitory on Sunday night were drawn mainly from the deprived local hill tribes, who live too far away to travel to school every day.
Television interviewed one girl aged around 10 who escaped with several friends.
‘I woke up and saw a lot of smoke. It was dark. The fire had broken out downstairs so I called to my friends’ she said, describing her flight.
But those who did not wake up in time died.
‘There were 38 students inside the dormitory when the fire broke out. Some were not yet asleep so they escaped,’ deputy provincial governor Arkom Sukapan told AFP, confirming the death toll.
‘But others were asleep and could not escape, resulting in the large number of casualties.’
Photographs on the school's Facebook page showed firefighters struggling to douse the flames as they tore through the building.
Thai media showed a fire truck spraying water onto the blaze as the upper storey was consumed by the fire.
Thailand is home to a patchwork of hill tribes who mainly live in the remote northern area bordering Laos and Myanmar.
Many are descendants of refugees from Myanmar or China and exist within subsistence farming communities with their own distinctive dialects and rituals.
They mostly live beyond the reach of state resources, meaning hill tribe children suffer at school as well as in their health and development.
Poverty means adults are easy prey for drug gangs who pay them to smuggle narcotics -- including heroin and amphetamines -- across the zone, known as the ‘Golden Triangle’.
Thai security forces frequently engage in deadly gunbattles with hill tribe drug mules in the region.
That link engenders prejudice among many Thais and hill tribes are often portrayed negatively in the media.
Chiang Rai town and the surrounding hills are popular with foreign tourists for hiking and adventure sports.
Visitors can go on tours to see the isolated tribes, although the practice of taking posed photographs at villages has come in for criticism.
Thailand has poor health and safety standards and accidents are common across the kingdom.