The soldier reportedly opened fire at a shopping mall in the city of Nakhon Ratchasima, northeast of the capital, Bangkok. Authorities shot the suspect dead after he spent hours holed up in the mall.
Thai authorities confirmed on Sunday that a soldier who killed 29 people in a shooting rampage in a mall had been shot dead by security officials.
The killing spree took place on Saturday, in the northeastern city of Nakhon Ratchasima.
Public Health Minister Anutin Charnvirakul said more than 31 others were injured.
"Thank you police and army for ending the situation. Shooter shot dead!!!" Anutin later wrote on Facebook.
The soldier had reportedly opened fire at a shopping mall following a dispute over land. Video taken outside the Terminal 21 mall and shared on social media showed people taking cover in a parking lot as gunshots were fired.
Prime Minister Prayuth Chan-ocha expressed condolences to the families of the victims.
DW's correspondent in Thailand, Florian Nusch, said the health minister was encouraging people in the local region to go to hospitals to donate blood.
What happened in the shooting rampage?
Authorities said the suspect was stationed at an army base outside of Nakhon Ratchasima — around 250 kilometers (155 miles) northeast of the capital, Bangkok — and initially shot dead a fellow soldier and a woman there. He is then alleged to have stolen weapons and a military vehicle from the barracks before driving to the mall.
Security personnel stormed the building where the suspect spent hours holed up and helped hundreds of shoppers to evacuate the area. Police announced shortly before midnight local time that they had "taken control" of the entire mall, but the gunman was still in the building.
News that he had been shot came shortly after 09:00 local time.
"As for the motive to the incident, we have to wait for officials to catch him and interrogate him first," military commander Lieutenant General Thanya Kiatsarn said in a statement earlier.
Suspect posted messages on social media
The suspect, identified by the Defense Ministry as Sgt. Jakrapanth Thomma, posted messages on his Facebook page during his alleged rampage, writing "No one can escape death" and "Should I give up?"
Facebook later said that it had removed the account and would "work around the clock to remove any violating content related to this attack as soon as we become aware of it."
"Our hearts go out to the victims, their families and the community affected by this tragedy," a Facebook representative said in a statement. "There is no place on Facebook for people who commit this kind of atrocity."
While it is legal to own firearms in Thailand, mass shootings there are unusual.
"Thailand is among the leading nations when it comes to private gun ownership, so [there are] a lot of guns in this country," DW's Florian Nusch said. "Someone who actually goes on a rampage, who posts his actions online, who targets [people] indiscriminately — this is something very, very rare here in Thailand."
nm,es,ed/shs (AP, AFP, Reuters)