A Taliban suicide bomber dressed as a labourer blew himself up at the NATO airbase 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 on Saturday, and 16 other US service members were wounded, along with a Polish soldier who was part of the NATO mission.
"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," US defence chief Ashton Carter said in a statement.
The explosion struck at dawn on Saturday inside the heavily fortified Bagram based as the Taliban steps up attacks on western targets before the onset of winter, when fighting usually ebbs.
Waheed Seddiqi, spokesman for the Parwan provincial governor, said the bomber managed to enter the heavily protected site and was standing in a queue with Afghan labourers when he detonated a suicide vest.
Bagram Airfield, close to Kabul, has frequently come under attack by Taliban fighters.
No consensus in Afghanistan on how to deal with Taliban
Al Jazeera's Abdullah Shahood, reporting from Kabul, said the base is in a heavily guarded area where people only with exclusive access can enter.
"An Afghan police official told us that the person who got in with the explosives must be a dual citizen and someone who has an access pass and is trusted to go without escort," he said.
On Thursday, four people were killed and 128 others were wounded when a suicide bomber drove a lorry loaded with explosives into the German consulate in the northern city of Mazar-e Sharif.
The Taliban said that attack was retaliation for air strikes near the northern city of Kunduz last week, which killed more than 30 civilians.
Taliban spokesman Zabihullah Mujahid said Saturday's blast - which he said had been planned for four months - had caused heavy casualties, killing 23 Americans and wounding 44. The group often exaggerates the number of casualties caused by its operations.
The explosion underscores a worsening security situation nearly two years after NATO formally ended its combat operations in Afghanistan.
The US currently has about 10,000 troops in Afghanistan, with the largest contingent stationed at Bagram Airfield.
Last December, a motorcycle-riding Taliban suicide bomber killed six US soldiers near Afghanistan's largest US military base. It was one of the deadliest attacks on foreign troops in the country in 2015.
Source: News Agencies