The attack lasted several hours but was over by early evening, according to the spokesman, who wished to remain anonymous.
US General John Nicholson, commander of NATO's Resolute Support operation, said in a separate statement that the attack targeted "soldiers at prayer in a mosque and others in a dining facility" of the 209th Corps of the Afghan army.
The general, who did not give a toll, praised "the Afghan commandos who brought today's atrocity to an end".
Afghan defence ministry spokesman General Dawlat Waziri said gunmen wearing Afghan army uniforms had launched the attack on the army compound on the outskirts of Mazar-i- Sharif, capital of Balkh province.
"In total, there were 10 attackers involved in the attack on the Afghan army corps. Seven of them were killed, two blew themselves up, and one was detained by Afghan forces," Waziri told AFP.
The Afghan general earlier gave a toll of eight soldiers killed and 11 wounded but said this would change.
Several military helicopters were hovering over the site and ambulances were evacuating the bodies of the victims, an AFP correspondent said.
In a statement the Taliban claimed responsibility for the operation.
The last major attack against a military site dates back to early March, a coordinated hours-long assault on the country's main military hospital in Kabul.
Officials said around 50 people were killed in that attack, though credible sources said it was more than double that.
That operation was claimed by the Islamic State group.
You’ve reached your limit of {{free_limit}} free articles this month.
Subscribe now for unlimited access.
Already subscribed? Log in
Subscribe to read the full story →
Smart Quarterly
₹900
3 Months
₹300/Month
Smart Essential
₹2,700
1 Year
₹225/Month
Super Saver
₹3,900
2 Years
₹162/Month
Renews automatically, cancel anytime
Here’s what’s included in our digital subscription plans
Exclusive premium stories online
Over 30 premium stories daily, handpicked by our editors


Complimentary Access to The New York Times
News, Games, Cooking, Audio, Wirecutter & The Athletic
Business Standard Epaper
Digital replica of our daily newspaper — with options to read, save, and share


Curated Newsletters
Insights on markets, finance, politics, tech, and more delivered to your inbox
Market Analysis & Investment Insights
In-depth market analysis & insights with access to The Smart Investor


Archives
Repository of articles and publications dating back to 1997
Ad-free Reading
Uninterrupted reading experience with no advertisements


Seamless Access Across All Devices
Access Business Standard across devices — mobile, tablet, or PC, via web or app
)