Jakraphanth Thomma on Saturday killed his commanding officer before stealing weapons from a military camp.
The suspect continued his attack in a shopping centre in Nakhon Ratchasima, also known as Korat,
He posted material to social media, but his motives for his actions remain unclear.
Public Health Minister Anutin Charnvirakul posted on his Facebook page on Sunday morning, congratulating the security forces for their actions in the northeastern Thai town.
"Thank you police and army for ending the situation. Shooter shot dead!!!"
Officials said that the death toll stood at 20, with 42 wounded, revising an earlier total of 21 dead. However, it is still possible that the number of fatalities could rise.