The Thai soldier who killed at least 21 people and holed up in a mall overnight was "shot dead" on Sunday morning, police said, ending a near-24-hour ordeal which has stunned the country.
He was killed "thirty minutes ago" (0200 GMT), chief of the Crime Suppression Division Jirabhob Bhuridej told AFP. The health minister and police chief confirmed the gunman's death.
The Thai soldier, after his shooting spree, remained holed up in a shopping mall on Sunday morning with an unknown number of people feared trapped inside, despite repeated attempts by armed police to flush the gunman out.
Volleys of gunfire rang out before dawn, hours after Thai security services stormed the ground floor of the Terminal 21 mall in Nakhon Ratchasima - also known as Korat - where the gunman held out, armed with assault weapons stolen from his barracks.
Scores of stunned and terrified shoppers fled the shopping centre as police entered the mall, escaping a bloody rampage that the gunman relayed via Facebook posts.
The attacker has been identified as a junior army officer named Sergeant-Major Jakrapanth Thomma.
Automatic weapon fire rang out just before dawn as ambulances prepared to evacuate the wounded in an attack whose motives remain unclear, seeding fear among the rescuers and media massed near the mall.
At least 10 people were in critical condition in hospital, according to the Thai Health Minister, raising fears the toll will rise.
As shoppers made a break for the exits late Saturday, police from the Crime Suppression Division urged evacuees to "raise their hands" and identify themselves on the ground floor amid fears the gunmen could hide among the desperate crowds.
Earlier Jakrapanth relayed his shooting spree through Facebook posts which charted the attack from army barracks in the city to the mall, where an unknown number of shoppers remained trapped.
Hospitals across the country braced for a grim night ahead as residents flooded the hospitals to give blood and search for relatives.
The bloodshed began Saturday afternoon when Jakrapanth shot three people -- among them at least one soldier -- at a senior officer's house and then at nearby army barracks, before driving an army vehicle to the town centre.
There the gunman used weapons stolen from the military arsenal to bring carnage to a town centre.
Jakrapanth's motive remains unclear. But throughout the day he posted images of himself and wrote several posts on his Facebook page as the attack unfolded, including "should I surrender?" and "no one can escape death".
In one Facebook video -- since deleted -- the assailant, wearing an army helmet, filmed from an open jeep saying, "I'm tired... I can't pull my finger anymore" and making 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 Thailand's largest barracks in a country where the military is enmeshed in politics and society.
Thailand has one of the highest rates of gun ownership in the world. Several shootings at courthouses late last year renewed concern about gun violence in the southeast Asian country.
(With AFP Inputs)