The gunman has been named as Panya Khamrab, 34, who was dismissed from the police force last year for drug use.
A former police officer has shot dead at least 37 people, most of them children, after he stormed a nursery in Thailand in one of the kingdom's deadliest mass killings.
Following the attack, gunman Panya Khamrab went home and killed his wife and child before taking his own life, police said on Thursday.
Armed with a shotgun, pistol and knife, Panya opened fire on the childcare centre in northeastern Nong Bua Lam Phu province at about 12:30 pm (0530 GMT).
National Police Chief Damrongsak Kittiprapat told a news conference the gunman killed 37 people, including 23 children and his own family, and wounded 12 others.
Nanthicha Punchum, acting chief of the nursery, described harrowing scenes as the attacker barged into the building.
"There were some staff eating lunch outside the nursery and the attacker parked his car and shot four of them dead," she told AFP news agency.
"The shooter smashed down the door with his leg and then came inside and started slashing the children's heads with a knife."
Footage after the incident showed distraught parents weeping in a shelter outside the nursery, a yellow single-storey building set in a garden.
The 34-year-old gunman was a former police sergeant suspended in January and sacked in June for drug use, Damrongsak told reporters.
UPDATE: Gunman in Thailand mass shooting has killed his wife, his child and himself — Thai media— TRT World Now (@TRTWorldNow) October 6, 2022
Thailand forms part of Southeast Asia's so-called Golden Triangle which has long been an infamous hotspot for the trafficking and abuse of drugs.
Surging supplies of methamphetamine have sent street prices crashing in Thailand to all-time lows, according to the UN Office on Drugs and Crime.
The mass killing comes less than a month after a serving army officer shot dead two colleagues at a military training base in the capital Bangkok.
While Thailand has high rates of gun ownership, mass shootings are extremely rare. But in the past year, there have been at least two other cases of shooting murders by serving soldiers, according to the Bangkok Post.
In 2020, in one of the kingdom's deadliest incidents in recent years, a soldier gunned down 29 people in a 17-hour rampage and wounded scores more before he was shot dead by commandos.
That mass shooting, linked to a debt dispute between gunman Sergeant-Major Jakrapanth Thomma and a senior officer, triggered public anger against the military.
The soldier was able to steal assault rifles from an army depot before embarking on his killing spree, posting live updates on social media as he did so.
Military top brass were at pains to portray the killer as a rogue soldier.