Hundreds of people have been rescued from a Thai shopping mall after a soldier opened fire inside the shopping centre, killing at least 20 people and injuring 31 others.

The soldier shot and killed his commander at the Surathampithak army camp before stealing weapons and ammunition and fleeing in a stolen Humvee at 3.30pm local time on Saturday.

He then drove to the Terminal 21 shopping mall, which was busy with people celebrating a long weekend, and fired at civilians.

A soldier opened fire in a busy Thai shopping mall, killing 20 people. Photo / Supplied
A soldier opened fire in a busy Thai shopping mall, killing 20 people. Photo / Supplied

The gunman live-streamed the mass shooting on Facebook and posted selfies on the platform before his profile was taken down by the social media giant.

Advertisement

"The gunman used a machine gun and shot innocent victims resulting in many injured and dead," said Pol Col Krissana Pattanacharoen, the police spokesman.

Defence Ministry spokesman Lt Gen Kongcheep Tantrawanit said late Saturday that 20 deaths had been confirmed. Another 31 people were reported injured, some seriously, Bangkok Post reported.

 Armed forced have rescued all civilians from a shopping mall in Thailand after a soldier opened fire and killed at least 20 people. Photo / AP
Armed forced have rescued all civilians from a shopping mall in Thailand after a soldier opened fire and killed at least 20 people. Photo / AP

Officers who stormed the building late Saturday urged the gunman to surrender but they were met with angry shouts and more gunfire.

Troops from a special warfare unit were dispatched to the mall, where the attacker was said to be holding 16 people hostage on the fourth floor.

"We don't know why he did this. It appears he went mad," said defence ministry spokesman Kongcheep Tantrawanit.

People who were able to get out of Terminal 21 Korat mall walk outside the building in Nakhon Ratchasima, Thailand. Photo / AP
People who were able to get out of Terminal 21 Korat mall walk outside the building in Nakhon Ratchasima, Thailand. Photo / AP

Police Crime Suppression Division commandos arrived from Bangkok by helicopter. Police also brought the man's mother in hopes that she could persuade him to surrender, Bangkok Post reported.

Around 8.30pm, it was reported that special forces troops were preparing to "engage" the shooter inside the shopping centre.

But the immediate focus was on safely evacuating the hundreds of shoppers and workers who were still trapped inside.

Advertisement

Police said around 11.30pm that they had taken control of floors G, 1, 2 and 3 in the mall.

Lt Gen Thanya Kriatisarn, commander of the Second Army Region, identified the suspect as Sgt Maj Jakrapanth Thomma, 32, of the Surathampithak camp.

The man believed to be the gunman posted updates to his Facebook page during the rampage with statements including "No one can escape death" and "Should I give up?" In a later post he wrote, "I have stopped already."

This screenshot made from the Facebook livestream video of Thai soldier Jakrapanth Thomma during an attack northeast of Bangkok. Photo / Facebook
This screenshot made from the Facebook livestream video of Thai soldier Jakrapanth Thomma during an attack northeast of Bangkok. Photo / Facebook

His profile picture shows him in a mask and dressed in military-style fatigues and armed with a pistol. The background image is of a handgun and bullets.

In a photo circulated on social media that appeared to be taken from his Facebook page, the suspect can be seen wearing a green camouflaged military helmet while a fireball and black smoke rage behind him. The Facebook page was made inaccessible after the shooting began.