Attackers used military uniforms and vehicles to pass three checkpoints before launching their attack, an Afghan army official said.
At least 80 Afghan soldiers were killed and several wounded on Friday when Taliban gunmen attacked a military headquarters in northern Afghanistan, officials said.
Afghan commandos were deployed during the attack which lasted several hours and targeted soldiers as they prayed at a mosque and ate lunch.
Two of the 10 attackers blew themselves up while seven were killed and one was detained.
"More than 80 Afghan soldiers have been killed" in a Taliban attack on their base near the northern city of Mazar-i-Sharif, a US military spokesman said.
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 US has around 8,400 troops in the country with about another 5,000 from NATO allies assisting a much larger Afghan force in the war against the Taliban and other militants.
Nicholson in February told the US Senate Armed Services Committee in Washington that he needed "a few thousand" more troops to help train and assist the Afghan forces.
Afghan defence ministry spokesman General Dawlat Waziri said gunmen wearing Afghan army uniforms had launched the assault 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 said.
The attack began at around 2pm (0930 GMT) and was over by early evening, he said.
Taliban spring offensive
The Afghan defence ministry gave an initial toll of eight soldiers killed and 11 wounded.
Several military helicopters hovered over the site during the attack and ambulances evacuated the bodies of the victims, an official said.
In a statement the Taliban claimed responsibility for the attack.
The Taliban are preparing to launch their traditional spring offensive, although the lull in the fighting season was only partial this year.
The last major attack against a military site was in 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, while other sources said it was more than double that. Daesh claimed responsibility for that attack.