Thai security forces on Sunday shot and killed a rogue soldier who went on a rampage in a shopping mall in a northeastern city, ending an overnight siege after a series of attacks that left at least 27 people dead.

Public Health Minister Anutin Charnvirakul confirmed the soldier had been shot dead at the Terminal 21 mall in the city of Nakhon Ratchasima.

"Thank you police and army for ending the situation. Shooter shot dead!!!" Public Health Minister Anutin Charnvirakul said in a post on Facebook.

Police and the army also said he had been killed.

Police have identified the suspected shooter as 32-year-old soldier Jakrapanth Thomma.

Earlier, Charnvirakul told reporters at the scene that one member of the security forces was killed and two wounded in the raid as they tried to stop the rampage.

An injured member of Thai security forces is stretchered out after a raid inside the Terminal 21 shopping mall. (Athit Perawongmetha/Reuters)

The killings began at around 3 p.m. 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.

Thai media said the suspected shooter had worked at an army base close to Nakhon Ratchasima, about 250 kilometres from Bangkok, Thailand's capital. Before the attack, Jakrapanth had posted on his Facebook account that he was out for vengeance — but he did not say for what.

A provincial health official told a news conference that a total of 26 people had been killed and 57 wounded, revising earlier figures given by other officials.

Hundreds of people rescued

"We don't know why he did this. It appears he went mad," Defence Ministry spokesman Kongcheep Tantrawanit told Reuters.

Overnight, soldiers and police stormed into the mall and escorted hundreds of trapped people to safety.

Thai security forces evacuate students stranded inside the Terminal 21 shopping mall following a gun battle to try to stop a soldier on a rampage. (Athit Perawongmetha/Reuters)

"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.

CCTV footage from inside the mall 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.

Vehicles block the road in front of Terminal 21 Korat mall on Sunday. (Sakchai Lalitkanjanakul/Associated Press)

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

Nakhon Ratchasima is one of the biggest cities in northeastern Thailand, an island of relative prosperity in a rice growing area that is one of the poorest parts of the country of 69 million people.