Thailand’s prime minister has denied suggestions that arms were not properly secured at a military base where a rogue soldier stole multiple weapons before killing at least 29 people in a mass shooting.

Prayuth Chan-ocha described the attack as unprecedented and responded abruptly when he was asked about details of the operation to stop the attack and about the theft of the weapons.

“This was not carelessness. We don’t leave the arsenal depot alone – we had people guarding it,” he told reporters. The gunman was killed by police on Sunday morning following an overnight operation.

Eight people were reportedly held hostage by the gunman, who had holed himself inside a shopping mall after firing at drivers, pedestrians and shoppers. Scores more were trapped for hours on Saturday night as police attempted to regain control of the seven-floor shopping centre in Nakhon Ratchasima.

One police officer was killed during the raid. Anutin Charnvirakul, Thailand’s health minister, said: “He had been hit and unfortunately he couldn’t make it.”

Lt Gen Kongcheep Tantrawanich, a defence ministry spokesman, named the gunman as Jakrapanth Thomma, who held the rank of sergeant major. Prayuth, who travelled to Nakhon Ratchasima to visit wounded survivors on Sunday, said the soldier was motivated by a grudge over a land deal in which he felt he had been cheated

The attack began late on Saturday afternoon when the gunman fired at a house in Muang district of Nakhon Ratchasima. He moved on to an army barracks, killing the commanding officer of the 22nd Ammunition Battalion, in which he served.

Jakrapanth, who livestreamed some of the attacks on social media, stole two rifles, an M60 machine gun and 736 rounds of ammunition, according to officials. He then drove to the city centre in a Humvee-type vehicle and shot at people outside and inside the Terminal 21 shopping centre.

“I can’t run away because I don’t know where the shooter is. I am here with about 20 people,” one man, who called himself Mr Green, told the Thai state broadcaster MCOT on Saturday night from inside the mall.

Nattaya Nganiem and her family were leaving the mall at the time of the attack. “First I saw a woman run out from the mall hysterically,” Nattaya, who shot a video of the scene on her phone, told the Associated Press. “Then a motorcycle rider in front of her just ran and left his motorcycle there.”

Another woman, Ms Uam, said she hid with 30 people inside a storage room, where they stayed for about six hours with the lights turned off. “All of us switched off our phones. No one posted anything on social media,” she told Thairath TV. She was later able to flee at about 11pm local time.

Footage apparently taken inside the mall during the attack showed people running from stalls to take cover. “It was about 5pm that I heard the gunfire,” said Uam. “Then a crowd started running. I could see it clearly because I was in front of the mall. I saw him shooting and I saw him moving in front of the parking lot where he later took a selfie that he posted on Facebook.”

CCTV images showed the gunman walking through an empty section of the mall carrying a rifle and dressed in his soldier’s uniform.

In videos taken by witnesses on the main road outside of the shopping centre, the sound of repeated gunfire could be heard. During the attack the gunman posted images and videos to his Facebook page, which were later removed. Faceboook said in a statement: “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.”

During the attack, the National Broadcasting and Telecommunications Commission urged the media, as well as people inside the mall, not to share live footage of police operations, amid reports that the suspect was using such livestreams to evade authorities. The commission’s secretary-general, Takorn Tantasith, later announced he would summon journalists over their coverage of the attack.

“From our investigation and our follow-up check, NBTC found that some stations did not strictly comply to the commands,” Takorn said in a statement.

The incident has shocked Thailand. While the country has high rates of gun ownership, such attacks are rare outside of the far south where an insurgency has continued for decades.

“It is unprecedented in Thailand, and I want this to be the last time this crisis happens,” Prayuth said.

Associated Press, Reuters and Agence France-Presse contributed to this report.