A Thai soldier who killed at least 26 people before being shot dead in a mall by commandos went on the rampage because of a debt dispute, the kingdom's premier said Sunday, offering the first official motive for the "unprecedented" shooting spree.
Sharp-shooters brought an end to a 17-hour-ordeal when they killed the gunman on Sunday morning after a night which seesawed between heavy exchanges of gunfire and terrifying dashes for mall exits by shoppers trapped in the Terminal 21 mall in Nakhon Ratchasima, also known as Korat.
Twenty-six people including civilians -- the youngest a 13-year-old boy -- and security forces were killed by the rogue soldier, said Thailand's prime minister Prayut Chan-O-Cha.
"It is unprecedented in Thailand, and I want this to be the last time this crisis happens," he said outside a hospital where victims were being treated.
At least two were undergoing brain surgery.
Prayut, a former army chief, blamed a "personal problem" over the sale of a house for the soldier's rampage, which began on Saturday afternoon near an army barracks and was for several hours relayed by the gunman via Facebook posts.
The attacker, a junior army officer identified as Sergeant-Major Jakrapanth Thomma, used a stolen M60 machine gun and rifles from one of Thailand's largest barracks as well as a military humvee to carry out the attack.
Prayut said he overpowered security at the barracks' arsenal.
"This was not carelessness. We don't leave the arsenal depot alone -- we had people guarding it."
Most of the dead were killed in and around the mall.
Volleys of gunfire rang out as the siege ran into dawn, hours after Thai security services stormed the ground floor and freed scores of terrified shoppers from the rampage.
Frightened shoppers sent cascades of messages to friends and family on social media from storerooms, barricaded in toilets and hidden under tables as the gunman stalked the mall.
With the machine gun slung over his shoulder and in full combat gear, Jakrapanth swaggered through the emptied out floors in haunting footage captured by CCTV cameras.
Evacuees recounted how an ordinary Saturday at the busy shopping centre descended into horror as he entered, sparking an hours-long ordeal.
"It was like a dream... I'm grateful I survived," Sottiyanee Unchalee, 48, told AFP, explaining she hid in the toilet of a gym inside the mall as she heard the gunfire.
Filipino teacher Aldrin Baliquing said he was ushered into a storeroom by staff as the shooting began.
"We were there for six gruelling hours... I'm in shock," he said.
Scores of people made a dash for it as police and soldiers in masks and wielding assault rifles took control of the ground floor following a gun battle and scoured the fleeing crowds for the assailant.
- 'Like a Zombie movie' -
"It was total panic, it was like a zombie movie," Chanatip Somsakul, 33, said of the escape with his wife and three-year-old daughter.
"People jumped on motorbikes and ran in all directions."
Several hours later the gunman was shot dead. Photos showed smiling units of elite soldiers and police emerging from the mall.
The gunman relayed his shooting spree through Facebook posts which charted the attack from an army barracks to the city mall.
Despite the prime minister's speculation Jakrapanth's, exact motive remained unclear as Korat -- a sedate and mid-size town -- tried to digest the scale of the atrocity.
The bloodshed began Saturday afternoon when he shot three people -- among them at least one soldier -- at a senior officer's house and then at the nearby army barracks, before driving a military vehicle to the town centre.
There the gunman used the stolen weapons to unleash carnage in the town centre.
Throughout the day he posted images of himself and wrote several posts on his Facebook page.
In one Facebook video -- since deleted -- the assailant, wearing an army helmet, filmed from an open-top jeep, saying, "I'm tired... I can't pull my finger anymore" as he made a trigger symbol with his hand.
There were also photos of a man in a ski mask holding a pistol.
Thailand's digital economy minister Buddhipongse Punnakanta said he contacted regional executives at the social media giant to report the activity.
"I think this might be the first time that this happened in Thailand and it caused a lot of problems," he told AFP.
A Facebook spokesperson said the gunman's accounts were removed and it will "work around the clock to remove any violating content related to this attack as soon as we become aware of it."
Thailand has one of the highest rates of gun ownership in the world, and several shootings at courthouses last year renewed concern about gun violence.