Two US soldiers and an Afghan soldier were killed when an individual in an Afghan uniform opened fire on them with a machine gun in eastern Afghanistan, the US military and two senior Afghan officials said on Sunday.
The shootout on Saturday wounded six US service members and three Afghan soldiers. The firefight broke out after a combined US and Afghan force completed a "key-leader engagement" at the administrative headquarters of Nangarhar province's Shirzad district, a spokesman for US forces in Afghanistan said.
"Current reports indicate an individual in an Afghan uniform opened fire on the combined US and Afghan force with a machine gun," Colonel Sonny Leggett said the statement. "We are still collecting information and the cause or motive behind the attack is unknown at this time," he added.
The Taliban has not claimed responsibility for the attack and senior officials were investigating if it was an insider attack - often known as "green-on-blue" attacks that have been a regular feature of the conflict in Afghanistan.
Afghanistan's defence ministry, in a statement on Sunday, said the attacker opened fire on Afghan National Army members and US forces, killing one Afghan soldier and wounding three others alongside the American soldiers.
The ministry set up an investigations team headed by the country's chief of army staff to investigate the attack. "Attacks such as this by our enemies fail to have negative effects on the friendship and spirit of cooperation and between the Afghan National Security Forces and the US military," the ministry said.
Sohrab Qaderi, a provincial council member in Nangarhar, said the attacker was killed in the clash. He said the Islamist fighter had infiltrated the Afghan security forces involved in the joint operation, but did not say which group the militant belonged to.
There have been fewer of these incidents in recent years as the Americans have taken more of a supporting role, with Afghan forces leading the fight. Though last year the top American and NATO commander in Afghanistan, General Austin Miller, survived a shooting by a Taliban infiltrator in an Afghan military uniform. A top Afghan general walking next to him was killed.
The latest shooting comes at a delicate time, with American and Taliban negotiators pushing for a peace deal. Nangarhar, which shares a long and porous border with neighboring Pakistan, had long served as stronghold for Islamic State in Afghanistan, though the Taliban also controls parts of the province.
About 14,000 US troops are stationed in Afghanistan as part of the US-led NATO mission to train, assist and advise Afghan forces and to carry out counter-terrorism operations.