Although the killings appear to have stemmed from a disagreement rather than a rebel attack, they highlighted the prevailing insecurity in Afghanistan, 10 years after a US-led invasion ousted the Taliban from power.
The deaths also raise fresh questions over the massive NATO-led effort to expand and train Afghanistan's military and police so they can take control of security when foreign combat operations end in 2014.
Separately, two more foreign soldiers died in two different incidents, the NATO force in the war-torn country said, making it a particularly bloody day even by Afghanistan's standards. Their nationalities were not released.
|An Afghan soldier keeps watch at the gate of the Afghan air force compound in Kabul.|
The NATO-led International Security Assistance Force (ISAF) confirmed that eight of its troops and one civilian who were training Afghan forces died in the shooting at NATO's Air Training Command Afghanistan centre on a site shared by Kabul's military and civilian airports.
A Pentagon spokesman said all nine fatalities were American.
Afghan defence ministry spokesman Mohammad Zahir Azimi said the shootings happened at around 11:00 am (0630 GMT) when "an argument took place between an (Afghan) air force officer and foreign colleagues".
Colonel Mohammed Bahadur Raeeskhail, the Afghan air force's media relations chief, said Afghan and international staff had gathered in a conference hall for a regular briefing.
He identified the 45-year-old gunman as a former pilot who had been working as an air force administrator.
"We don't know what exactly happened to trigger the shooting," added Raeeskhail. It was also not immediately clear if all nine Americans died from bullets fired by the former pilot or if some were caught up in the crossfire.
The gunman was shot dead by Afghan soldiers following the killings.
The Taliban claimed responsibility in a text message to AFP, but are known routinely to exaggerate their claims.
An Afghan official, speaking on condition of anonymity, said the gunman was from a well-respected Kabul family and that the shooting was the result of a disagreement, not terrorism.
He is thought to have used a pistol in the shooting, the source added.
President Hamid Karzai condemned the incident, saying that five members of the Afghan air force were also wounded. He vowed to launch an investigation.
The deaths represent the highest number of foreign forces killed in a single incident since September, when nine ISAF troops died in a helicopter crash.
It is also thought to be the deadliest incident for NATO troops targeted as they trained up Afghan forces.
There is a history of Afghan troops attacking foreign soldiers who have been mentoring them ahead of limited foreign troop withdrawals, the next of which is due to start in July.
Last November, six US troops were shot dead during a training session in eastern Afghanistan, apparently by a member of the Afghan border police.
NATO efforts to train and equip local forces so they can take responsibility for security across Afghanistan by 2014 have also been hit by a string of recent attacks by militants who have apparently infiltrated the armed forces or who attacked while wearing unauthorised uniforms.
The defence ministry in Kabul was targeted last week by a gunman in army uniform wearing a suicide vest, in an attack that left three people dead.
The Taliban-led insurgency is killing more foreign troops with every passing year, with two more added to the death toll after ISAF said an attack killed a NATO soldier in the east and a crude bomb left another dead in the south.
The latest casualties came as US media reported that President Barack Obama was to nominate his war commander in Afghanistan, General David Petraeus, to succeed Leon Panetta at the helm of the CIA.
ABC and NBC television reported that Petraeus will be replaced in Afghanistan by Lieutenant General John Allen, the current deputy head of US Central Command.
There are around 130,000 international troops serving in Afghanistan, the bulk of them from the United States, although Afghan forces are in control of security in Kabul.