A suicide bomber has killed four Americans inside Bagram airbase, the largest US military facility in Afghanistan.
US Defence Secretary Ash Carter said two members of the armed services and two contractors had died in the attack.
A further 16 US service members and one Polish soldier were injured, he added.
The Taliban said one of their fighters had carried out the attack, a major security breach in one of the best protected places in Afghanistan.
Bagram has been targeted by militants in the past but this is the first time a bomb has exploded inside the base.
Just north of the capital Kabul, it has been used as the main military base and airfield by the US-led forces and Nato over the past 14 years.
A local government spokesman said the attacker had entered the base early in the morning and was among Afghan labourers reporting for duty when he detonated his vest.
Mr Carter said he was “deeply saddened” by the US casualties and promised an investigation.
“Force protection is always a top priority for us in Afghanistan, and we will investigate this tragedy to determine any steps we can take to improve it,” he said.
Analysis – Waheed Massoud, Editor, BBC Afghan Service
Bagram is a heavily guarded military base with many layers of security and protection. The outermost layer is guarded by Afghan forces and second and more inner layers of security are guarded by US forces.
High walls, security cameras, and watch towers on the outer perimeters and inside the base are just some of its formidable security measures. A surveillance balloon also watches the entire area.
Every person entering the base is searched, in many cases escorted, and must have a pre-arranged meeting with someone inside.
The security measures serve not only to protect military personnel on the base, but also to safeguard expensive state-of-the-art military tools, including fighter jets and unmanned aerial technology.
US presidents visiting the country fly into Bagram, one of the most heavily guarded places in Afghanistan, because it is seen as more secure than landing in Kabul.
General John W Nicholson, US Army commander in Afghanistan, said in a statement:
”[To] the family and friends of those wounded in today’s attack, let me assure you they are receiving the best care possible, and we will keep them in our thoughts today.”
He said the incident was being investigated.
Nato Secretary General expressed his condolences on Twitter:
Taliban spokesman Zabihullah Mujahid said the attack had been planned over four months.
Last December, a Taliban suicide bomber riding a motorbike killed six US soldiers in a village near Bagram in one of last year’s deadliest attacks on foreign troops.
The attack on Bagram comes just a day after the German consulate in the city of Mazar-e-Sharif in northern Afghanistan was hit by a Taliban suicide bomb blast that killed six civilians and wounded some 120 others.
The Taliban said on Friday that those attacks were carried out in retaliation for a recent coalition air strike in Kunduz which reportedly killed some 30 civilians.
Correspondents say the Taliban are stepping up their attacks before the onset of winter.
Meanwhile, MPs in the Afghan parliament have dismissed the minister of foreign affairs, public works and social affairs for failing to spend development money allocated to them.
A BBC correspondent in Kabul says if the money is not spent, it will have to be refunded to the foreign donors.
Mr Ghani’s national unity government has been plagued by infighting since it was formed in 2014.
Ministers in Afghanistan are nominated by the president, and several more are due to face confidence votes by MPs.