[Getty/Kyodo]

BANGKOK - A Thai soldier killed 26 people and injured 57 others in a shooting rampage in northeastern Thailand before being fatally shot by security forces Sunday at a shopping mall where he had been holed up, officials said.

Prime Minister Prayut Chan-o-cha, speaking at a hospital, called the ordeal, which began Saturday afternoon at an army camp in Nakhon Ratchasima province, the worst mass shooting in the country's history.

The soldier, 31-year-old Jakrapanth Thomma, was killed around 9 a.m. inside the Terminal 21 mall, ending the 18-hour standoff, police chief Chaktip Chaijinda told a press conference in front of the mall.

The man was shot dead by police commandos in the basement of the multistory complex in an operation that also involved the military, according to the police.

The bloodshed began around 3 p.m. Saturday when the soldier allegedly shot dead his commanding officer and a woman at the senior officer's residence near Surathampitak army camp, the police said.

From there he headed to the base where he stole an army jeep and weapons and then set off in the vehicle, shooting indiscriminately at people and buildings including a Buddhist temple before arriving at the nearby mall, where he opened fire on shoppers and holed himself up.

Among the dead at the mall were a 9-year-old boy and police officer who took part in the raid, according to reports.

According to local media, during the early stages of the attack he posted updates to his Facebook page, saying at one point "I'm tired now" and asking whether he should give up.

Overnight, many shoppers escaped or were evacuated from the mall while gunfire was exchanged between the gunman and police.

Although the motive for the attack is unclear, local media reported that it may have stemmed from a financial dispute between the soldier and the commander.

"I thank you everybody, officials, private sectors, and people who jointly worked the whole night. We will overcome this together," Prayut said on his official social media account, as he visited some of the injured people in a local hospital.

The Japanese Embassy said it had no information of any Japanese being killed or injured in the incident.