Two American soldiers were killed in a so-called insider attack when a person in an Afghan military uniform turned his weapon on U.S. and Afghan forces at a joint base in the restive east of the country, coalition forces said on Monday.
Three policemen and two Afghan army officers were also killed in the attack, said a senior police official.
The attack took place as a deadline expired for U.S. special forces to quit the eastern province of Wardak, after Afghan President Hamid Karzai accused them and Afghans working for them of overseeing torture and killings in the area.
An Afghan interior ministry official said the attack occurred in Jalriz district of Wardak. It was not immediately clear if it was directed at U.S. special forces.
U.S. Secretary of Defense Chuck Hagel, who left Afghanistan early on Monday after a three-day visit, raised the sensitive issue of Wardak when he met Karzai.
U.S. forces have denied involvement in any abuses in Wardak.
Hagel sounded hopeful that a deal could be reached on their continued deployment, but acknowledged no breakthroughs were made in his talks with Karzai.
Afghans are divided over their expulsion, saying the departure of the U.S. special forces could leave a vacuum for insurgents to fill, which would pose a security risk for nearby Kabul.
Incidents involving Afghan security forces turning their weapons on the NATO-led forces who train them and fight Taliban insurgents have increased sharply over the past year.
The insider, or green-on-blue, attacks have seriously eroded trust between coalition and Afghan forces, who are under mounting pressure to contain the insurgency before most foreign troops leave by the end of next year.