A gunman described as a soldier angry over a financial dispute has killed two people and then gone on a far bloodier rampage in north-eastern Thailand, shooting as he drove to a busy mall where shoppers fled in terror.

At least 21 people were killed in all, 31 were injured and others were believed to be still inside the building as more gunshots rang out.

Defence Ministry spokesman Lieutenant General Kongcheep Tantrawanich said Sergeant Major Jakrapanth Thomma, 32, was behind the attack in Nakhon Ratchasima, a hub for Thailand’s relatively poorer and rural north-eastern region.

Much of the shooting took place at Terminal 21 Korat, an airport-themed mall filled with colourful Lego sculptures, a merry-go-round and huge replicas of landmarks from around the world.

Video taken outside the mall showed people diving for cover as shots rang out mid-afternoon on Saturday.

Many were killed outside the mall, some in cars, others while walking.

The killings began about 3:00pm (local time) on Saturday when the soldier opened fire in a house before moving to an army camp and then to the mall, posting messages on Facebook as he went.

Public Health Minister Anutin Charnvirakul told reporters at the scene that one member of the security forces was killed and two wounded in the raid.

As he spoke, a series of explosions and further shooting echoed from the Terminal 21 shopping centre.

Police closed off streets around the mall and kept journalists behind a security cordon.

After the raid, Reuters video images showed one casualty being wheeled out to an ambulance.

Another staggered from the building bare chested as he was helped onto a stretcher.

Nattaya Nganiem and her family had just finished eating and were driving away when she heard gunfire.

“First I saw a woman run out from the mall hysterically,” said Ms Nattaya, who shot video of the scene on her phone.

“Then a motorcycle rider in front of her just ran and left his motorcycle there.”

Ms Nattaya did not know the full extent of the carnage until she arrived home. When she learned of the death toll, she fainted.

“I can’t believe this is happening in my hometown,” she said.

“I mean, this shopping mall, we go there almost every other day.”

Facebook removes suspect’s account

It was unclear how many shoppers and workers remained inside the shopping mall after soldiers and police had earlier escorted hundreds of trapped people to safety, Lieutenant General Kongcheep said.

“It was frightening because I could hear the occasional gunshot … we waited a long time for the police to come and help us, many hours.” said Suvanarat Jirattanasakul, 27, her voice trembling after she emerged.

The mall was busy with shoppers on a long weekend for the Buddhist Makha Bucha holiday.

Thai media said the suspected shooter had worked at an army base close to Nakhon Ratchasima, which is about 250 kilometres from the capital Bangkok.

Before the attack, Jakrapanth had posted on his Facebook account that he was out for vengeance — but he did not say for what.

CCTV footage from inside the centre posted on social media showed the gunman dressed in black and wearing a mask, his gun slung over his shoulder with no sign of other people around.

Facebook said it had removed the suspect’s account.

“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,” a Facebook representative said in a statement.

Major shootings are rare in the South-East Asian country other than in the far south, where a decades-old insurgency persists.

‘We ran to hide in the toilets’

Mr Anutin said a doctor was shot while helping an injured person.

Hundreds of people were evacuated from the mall in small batches by police while they searched for the gunman.

“We were scared and ran to hide in toilets,” said Sumana Jeerawattanasuk, one of those rescued by police.

She said seven or eight people hid in the same room as her.

“I am so glad. I was so scared of getting hurt,” she said.

Shortly before midnight, police announced they had secured the above-ground portion of the mall, but were still searching for the shooter.

Mr Anutin said there were no more bodies left inside, but added, “we don’t know whether there are any additional injuries or deaths or not”.

Some shoppers remained trapped in the mall, presumably in the below-ground portion.

“We are worried for those who are still trapped inside. Some still couldn’t come out,” he said.

Lieutenant Colonel Poonsap Prasertsak, a senior police commander for the region, said police were in touch with some of those still trapped.

“We told them to stay calm, stay still and keep their heads down,” he said.