After a night which seesawed between heavy exchanges of gunfire and terrifying dashes for mall exits by trapped shoppers, sharp-shooters brought an end to the 17-hour-ordeal when they killed the gunman on Sunday morning 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, Thailand's prime minister Prayut Chan-O-Cha said.
"It is unprecedented in Thailand, and I want this to be the last time this crisis happens," he said outside a hospital where victims, including at least two undergoing brain surgery, were being treated.
Prayut, a gruff former army chief, blamed a "personal problem" over the sale of the 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, rifles and ammunition 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 an 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 stunned, terrified shoppers from a bloody rampage.
Frightened shoppers sent cascades of messages to friends and family on social media from cupboards, toilets and under tables as the gunman stalked the mall.
Shocked evacuees recounted how an ordinary Saturday at the busy shopping centre descended into horror as the gunman 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.
A Filipina 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," she 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.
Hours later he was shot dead. Photos showed smiling elite units of soldiers and police emerging from the mall.
Purported video from the scene -- shared on social media -- showed snipers in webbing on elevated walkways, aiming their rifles downwards as heavy gunfire echoed across a concourse below.
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 as the attack unfolded.
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 up a pistol.
A Facebook spokesperson said: "We have removed the gunman's accounts from our services and will work around the clock to remove any violating content related to this attack as soon as we become aware of it."
The city is home to one of the largest barracks in Thailand, a country where the military is enmeshed in politics and society.
The nation also has one of the highest rates of gun ownership in the world, and several shootings at courthouses last year renewed concern about gun violence.