TUNIS - A Tunisian soldier the authorities say had psychological problems seized a gun at a barracks on Monday and killed seven comrades before being shot dead himself.
The interior ministry said the rampage was not linked to "terrorism", but a defence ministry spokesman did not rule this out before an investigation reports on the incident.
Defence ministry spokesman Belhassen Oueslati said the corporal, whose name was not given, "had family and psychological problems".
Because of this, he had been "forbidden from carrying arms" and given "non-sensitive duties".
"He attacked one man with a knife and took his gun before shooting at his comrades who were saluting the flag," Oueslati said.
The incident "caused the deaths of seven soldiers and also of the shooter. Ten soldiers were wounded, and one is in a serious condition," he added.
Monday's shooting was at the Bouchoucha barracks in Tunis, not far from parliament and the Bardo National Museum where jihadist gunmen killed 21 foreign tourists and a policeman in March.
It triggered a security alert across the Bardo district, AFP correspondents reported.
One heard two volleys of gunfire from inside the barracks at around 8:45 am (0745 GMT), before an ambulance emerged, its siren blaring.
The interior ministry's elite Counterterrorism Brigade deployed in force across the area.
Police with sniffer dogs also checked parked vehicles for fear of car bombs in the district, which also houses two police barracks.
"The incident which took place at the Bouchoucha barracks is not connected with a terrorist operation," interior ministry spokesman Mohamed Ali Aroui told AFP initially.
The defence ministry's Oueslati said the shooter had been killed.
"The armed forces took control of the situation after firing on the soldier," Oueslati told AFP.
"Investigations will show whether this was a terrorist act or not," Oueslati told reporters, adding that all theories would be examined.
Mohsen Marzouk, political aide to President Beji Caid Essebsi, said the shooting "could lead to a review of many aspects of security in Tunisian barracks".
Tunis has been on high alert ever since the March massacre at the National Bardo Museum, which dealt a heavy blow to the North African country's tourism industry.
Tunisia has seen an upsurge in Islamist militancy since the Arab Spring revolt which toppled veteran strongman Zine El Abidine Ben Ali in 2011.
Since then, there has been a growing threat from armed jihadists, especially on the border with Algeria.
Some 70 members of the security forces, both police and soldiers, have been killed over the past four years, mostly in the rugged Mount Chaambi area.
Tunisia has also had to contend with the violence in Libya, its violence-ridden neighbour to the east where the Bardo attack killers underwent weapons training.
The porous desert border between the two countries has seen trafficking of all kinds, including in weapons, mushroom in recent years.