At least 29 people have been killed and 57 others wounded in an hours-long shooting spree in northeastern Thailand that ended in a shopping centre, where most of the victims were killed.

Officials said the attacker, a Thai soldier with a grudge, was fatally shot by security forces on Sunday morning after an overnight standoff at the complex in Nakhon Ratchasima city.

Here is what we know so far about the mass shooting:

What happened?

The attack began around 3pm (08:00 GMT) on Saturday, when the gunman, identified as Jakrapanth Thomma, opened fire in a house, before moving to an army camp and then to the shopping centre in Nakhon Ratchasima, about 250km (155 miles) from the capital, Bangkok.

Jakrapanth killed his commanding officer, Colonel Anantharot Krasae, then stole an assault weapon and ammunition from the army base's arsenal.

The gunman then fled the base and went on a shooting spree, opening fire indiscriminately at the Terminal 21 shopping centre.

He posted written messages on Facebook during the attack before his account was shut down by the social media network.

In a video he posted on Facebook that was later published by media outlets, Jakrapanth said, "I'm tired. I'm too tired to move my finger any more," as he gestured to his index finger while holding a gun.

In other posts he wrote messages such as "Should I surrender?" and "Three bodies were for revenge, the rest were self-defence".

Hundreds of people were seen fleeing the mall in groups as the police and army launched rescues during the more than 12-hour standoff. The shooter remained in the mall overnight before he was shot by police on Sunday.

Volleys of gunfire rang out as the siege ran on till dawn, hours after Thai security services stormed the ground floor and freed tens of terrified shoppers.

Purported video from the scene - shared on social media - showed snipers on elevated walkways aiming their rifles downwards as heavy gunfire echoed across a concourse.

The province's governor, Wichien Chantaranochai, on Sunday night said a total of 29 people had been killed by the attacker and 57 were wounded.

What did the survivors see?

Evacuees recounted how an ordinary Saturday at the busy shopping centre descended into horror as the gunman entered.

"It was like a dream ... I'm grateful I survived," Sottiyanee Unchalee, 48, told AFP news agency, explaining how she hid in the toilet of a gym inside the mall as she heard the gunfire.

Filipino teacher Aldrin Baliquing said he was ushered into a storeroom by staff as the shooting began.

"We were there for six gruelling hours ... I'm in shock," he said.

Frightened shoppers sent cascades of messages to friends and family on social media from their hiding spots in storerooms, toilets and under tables as the gunman stalked the mall.

Witnesses said the police took a long time before they were rescued.

"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," Suvanarat Jirattanasakul, a survivor of the attack, said.

Another shopper who escaped told local Amarin TV that the shooter was "aiming for the heads" and said his colleague died at the scene.

"I heard so many gunshots. He was shooting everywhere and his shots were very precise," said the man, identified as Diaw.

Thairath news outlet published security camera footage of the shooter in the mall, clad in black and holding a rifle.

"It was total panic, it was like a zombie movie," Chanatip Somsakul, 33, said of his escape with his wife and three-year-old daughter.

"People jumped on motorbikes and ran in all directions."

What have authorities said about the incident?

Prime Minister Prayuth Chan-ocha confirmed the shooter's death in a press briefing on Sunday and added that the government would shoulder the costs for victims' healthcare and funerals.

Prayuth said the shooting might have stemmed from a personal dispute over the sale of a house, although the exact motive remained unclear.

"They negotiated a home sale deal and had an argument about the payments involved. They were fighting for three days. No one thought it would escalate," the prime minister said.

Prayuth said Jakrapanth had overpowered security at the barracks' arsenal.

"This was not carelessness. We don't leave the arsenal depot alone - we had people guarding it."

Who was the attacker?

The shooter has been identified by authorities as 32-year-old soldier Jakrapanth Thomma. He worked at an army base about 250km (155 miles) from Bangkok.

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

Army sources said he was a sharpshooter who had taken many tactical courses, including planning ambushes, as well as a gun enthusiast who often posed with weapons on social media.

"The soldier that started this rampage was a really trained soldier. He was fully armed by robbing ammunition development. At the same time when he went to that mall there were a thousand people in there," Sean Boonpracong, former national security adviser to the Yingluck Shinawatra government said.