The Defense Ministry statement said the Taliban carried out the attack, but with the assistance of Afghan police and army personnel inside the base. It said 11 soldiers and six police were killed.
No one immediately took responsibility, but Taliban spokesman Zabihullah Mujahed said he would look into the allegation.
Provincial council member Assadullah Kakar had earlier given a higher toll of 25 killed, and said it was a Taliban attack with help from inside. It was not immdiately possible to resolve the conflicting accounts.
The attack comes as the U.S. and NATO start a staged withdrawal of their troops, in keeping with a peace deal signed last month between the United States and the Taliban.
The troop pullout is tied to promises by the Taliban to fight terrorism, including the Islamic State group's affiliate headquartered in eastern Afghanistan.
However, Washington has struggled to get Afghanistan's squabbling politicians to unite behind a single leader to start intra-Afghan negotiations, a critical next step in the U.S.-Taliban deal. Washington has also been critical of the violent attacks carried out be the Taliban targeting Afghan security forces, but not U.S. or NATO personnel.
Afghan President Ashraf Ghani's spokesman said Friday's “heinous” attack called into question the Taliban's commitment to the peace deal.
Ghani and his rival in last year's presidential polls had both declared themselves president in rival ceremonies earlier this month. Since then, Washington's peace envoy who brokered the U.S.-Taliban deal has been meeting the two leaders seeking a compromise. Until now the squabbling has only intensified.