The attack began just before midnight on Monday, the Afghan defense ministry said in a statement.
Government forces at Camp Achakzai in Shawali Kot district battled for several hours, killing at least 12 attackers, ministry spokesman Dawlat Waziri said.
Militants have stepped up attacks in Afghanistan in recent weeks.
The United States is considering whether to send 3,000 to 5,000 more military advisers to help train and assist Afghan security forces battling a 16-year-long insurgency led by the Taliban.
In another incident on Monday night, at least four civilians were killed and 13 wounded during a raid by Afghan special forces in the eastern province of Nangarhar, the provincial governor said.
Among the those killed were two women and a child, the governor’s office said in a statement. Six children and three women were among those wounded.
Defense Ministry spokesman Waziri said officials were aware of the report but had not confirmed it.
“An investigation is ongoing,” he said.
Afghan forces, backed by U.S. troops and air strikes, have been battling both Taliban and Islamic State-linked militants in Nangarhar, which is on the Pakistani border.