A Taliban suicide bomber dressed as a labourer has blown himself up at the NATO air base at Bagram north of the Afghan capital Kabul, killing four Americans and wounding at least 17 people.
Two US military service members and two US contractors were killed, and 16 other US service members were wounded, along with a Polish soldier who was part of the NATO mission, US Secretary of State Ash Carter said in a statement after Saturday's attack.
"For those who carried out this attack, my message is simple. We will not be deterred in our mission to protect our homeland and help Afghanistan secure its own future," Mr Carter said.
He said the military will investigate what happened to determine what steps could be taken to improve protection for the base.
The attack, which was claimed by the Taliban, underlines the foreign policy challenge that will face US President-elect Donald Trump when he takes office in January.
President Barack Obama had originally hoped to have all US forces out of the country by the end of his term, but was forced to abandon that goal as Afghan forces struggled to contain the Taliban insurgency.
Under current plans, 8400 US troops will remain as part of the Resolute Support operation and a separate US counterterrorism mission after Mr Obama decided to slow down a planned reduction of the force, leaving it to his successor to decide future strategy.
Waheed Sediqqi, spokesman for the Parwan provincial governor, said the bomber managed to enter the heavily protected site, the largest US base in Afghanistan, and was standing in a queue with Afghan labourers when he detonated a suicide vest.
The Taliban's spokesman, Zabihullah Mujahid, said Saturday's attack, which he said had been planned for four months, had caused heavy casualties, killing 23 Americans and wounding 44. The movement often exaggerates the number of casualties caused by its operations.