A soldier who killed 26 people in a gun rampage in the Thai city of Nakhon Ratchasima has been shot dead by the security forces, Thai police say.
Jakraphanth Thomma on Saturday killed his commanding officer before stealing weapons from a military camp.
The suspect continued his attack on the streets and in a shopping centre in Nakhon Ratchasima, also known as Korat.
The gunman, who posted material to social media, was shot dead after being cornered all night in the building.
Thailand's Prime Minister Prayuth Chan-ocha gave the higher death toll on Sunday, an increase from an earlier figure of 20. Fifty-seven people are wounded.
"It is unprecedented in Thailand, and I want this to be the last time this crisis happens," he said, after visiting the wounded at a hospital in Nakhon Ratchasima.
He said the motive for the attack appeared to be Jakraphanth's grudge over his belief that he had been cheated in a property deal.
Public Health Minister Anutin Charnvirakul posted on his Facebook page on Sunday morning, congratulating the security forces for their actions in the north-eastern Thai town.
"Thank you police and army for ending the situation. Shooter shot dead!!!"
What happened at the shopping centre?
Shortly after 03:00 local time (20:00 GMT on Saturday) gunfire was heard as the security forces raided the building, trying to dislodge the gunman.
Several people were led out of the centre, but there were concerns that more people were being held hostage.
At 09:30 (02:30 GMT) on Sunday, police confirmed that the gunman had been shot dead, but so far there are no more details about how the operation concluded.
Earlier reports said the gunman, aged 32, had tried to escape via the back of the building.
The suspect's mother was also brought to the shopping centre to try to persuade him to give himself up.
One of the people freed told the BBC how she and others hid in a bathroom on the fourth floor, before fleeing to the second and hiding under a restaurant table for three hours, hearing at least four gunshots before she saw some soldiers and could get to safety.
Charlie Crowson, a teacher of English who lives in Nakhon Ratchasima, told the BBC there were "bodies on the streets" of the normally peaceful town.
He said that one of his girlfriend's former students was among those killed in the attack that lasted for many hours.
How did the attack unfold?
It began at about 15:30 local time on Saturday (08:30 GMT) at the Suatham Phithak military camp, where the commanding officer, named by the Bangkok Post as Col Anantharot Krasae, was killed.
The Post said a 63-year-old woman, Col Anantharot's mother-in-law, and another soldier were also killed there.
The suspect seized arms and ammunition from the camp before taking a Humvee-type vehicle.
He then opened fire at a number of sites before arriving at Terminal 21 at about 18:00 local time (11:00 GMT).
Local media footage appeared to show the suspect getting out of his vehicle and firing shots as people fled.
CCTV footage showed him inside the shopping centre with a raised rifle.
What did the suspect post on social media?
He posted on his social media accounts during the attack, with one post on Facebook asking whether he should surrender.
He had earlier posted an image of a pistol with three sets of bullets, along with the words "it is time to get excited" and "nobody can avoid death".
Facebook has now taken the page down.
It said: "Our hearts go out to the victims, their families and the community affected by this tragedy in Thailand. There is no place on Facebook for people who commit this kind of atrocity, nor do we allow people to praise or support this attack."