Belhassen Oueslati said 10 others were injured in the shooting, including one person who was in a serious condition. He described the incident as an "isolated act, not a terrorist act" and said the motive will be determined by a probe.
Police reinforcements were sent to the area after the shooting, combing nearby streets, while a helicopter circled overhead. The Defense Ministry said a nearby school was also evacuated.
The shooting at the Bouchoucha barracks was about a kilometre from the museum.
Oueslati said the situation was under control by mid-morning.
He said the soldier had been forbidden from carrying a weapon after displaying "troubled behavior due to family problems" and had seized another man's weapon for the attack.
Since overthrowing its secular dictator in in 2011, Tunisia has been battling militant groups with links to the Islamic State group and al-Qaida, which have carried out attacks on security forces.