A former police officer armed with a gun and a knife attacked a childcare centre, leaving at least 38 dead on Thursday.
The gunman, identified as Panya Kamrab, 34, later shot his wife and child at home, before turning the gun on himself, said Thai police.
Police said Panya shot and stabbed teachers and children at the centre in the town of Uthai Sawan, 500km north-east of Bangkok in the province of Nong Bua Lamphu.
He also fired randomly at passers-by and rammed his truck into vehicles as he fled the scene.
According to the authorities, there were at least 22 children among the fatalities, some as young as two. At least 10 people were wounded, some severely.
The Nong Bua Lamphu provincial hospital sent out an urgent request for blood donations shortly after the shooting.
In a statement on Facebook, the Royal Thai police said that Panya was a police corporal at the Na Wang Police Station in Nong Bua Lamphu.
However, he was fired from the force in 2021 after he was found to have possessed drugs. He was also known to have abused drugs.
While the motive for the shooting is still unclear, police said that Panya had attended a court appointment related to drug offences before the incident, reported local media ThaiPBS.
National police chief Damrongsak Kittiprapas said that Panya, who had not quit his drug habit since his sacking, was due for another court appearance on Friday in a drug case that led to his dismissal.
“This might have led to hallucination from stress, and he eventually committed the crime, starting from the childcare centre, and later at his house,” said the police chief.
The massacre began around noon, when Panya forced his way into the childcare centre in the Na Klang district and opened fire, local media reported.
The children were believed to have been sleeping during the time of the incident.