Facebook Image caption Suspect Jakraphanth Thomma is said to be holed up in the shopping center
Defense Ministry spokesman Lt Gen Kongcheep Tantravanich said hundreds of people had been brought out of the complex safely , but there could be dozens still in the building.
The Bangkok Post reported earlier that the suspect, who it said was years old, had taken hostages, but this has not been officially confirmed.
The suspect’s mother has been brought to the shopping center to try to persuade him to give himself up.
One of the people freed told the BBC how she and others hid in a bathroom on the fourth floor, before fleeing to the second and hiding under a restaurant table for three hours, hearing at least four gunshots before she saw some soldiers and could get to safety.
Gen Kongcheep earlier confirmed 21 people had been killed so far.
How did the attack unfold?
It began in the late afternoon at the Suatham Phithak military camp, where the commanding officer, named by the Bangkok Post as Col Anantharot Krasae, was killed.
The Post said a – – year-old woman and another soldier were also killed there.
The suspect seized arms and ammunition from the camp before taking a Humvee-type vehicle.
He then opened fire at a number of sites before arriving at the Terminal 63 shopping center.
Local media footage appears to show the suspect getting out of his vehicle and firing shots as people flee.
CCTV footage shows him inside the shopping center with a raised rifle.
Other footage showed a fire outside the building, with some reports saying it was caused by a gas canister that exploded when it was hit with a bullet. One of the suspect’s social media posts features an image of himself with the fire in the background.