Two US soldiers and three Afghan commandos were killed on Saturday when a man in an Afghan military uniform opened fire.
At least six other American soldiers were wounded in the incident during a joint operation in Afghanistan’s eastern Nangarhar province as US and Afghan troops tried to secure an area under threat from the Taliban.
US Army spokesman Col Sonny Leggett confirmed the two American fatalities and said six were wounded in the firefight after the attack in the Sherzad district of Nangarhar.
“Upon completing a key-leader engagement at the district centre, current reports indicate an individual in an Afghan uniform opened fire on the combined US and Afghan force with a machinegun,” Col Leggett said.
He said the incident was under investigation but did not call it an insider attack, which are carried out by Afghans training with the US.
“We are still collecting information and the cause or motive behind the attack is unknown at this time,” Col Leggett said.
In a tweet, the US Army’s 7th Special Forces Group said several of its soldiers had been killed or injured during combat operations in Afghanistan.
Nangarhar provincial governor Shah Mahmood Meyakil said it was not clear whether the incident was a deliberate act by an “infiltrator” or an accident.
“It was not a clash between the forces. We are investigating,” Mr Meyakil said.
Col Leggett also said the cause or motive of the shooter was unknown.
The latest shooting comes at a delicate time, with the US and Taliban insurgents negotiating a peace deal.
The Taliban has not claimed responsibility for the attack, but they have conducted such assaults in the past two years, causing casualties among Afghan and foreign forces.
The insurgent group regularly shares updates on its social media accounts of Afghan troops who have surrendered guns to them.
In December, Taliban infiltrators in the military killed nine Afghan soldiers in central Afghanistan.
For years, the Afghan, US and coalition militaries have faced insider attacks.
If this is found to be another, it will be the seventh fatal insider attack in the past five years. They have been responsible for 12 casualties.
In 2018, a Taliban insider and bodyguard of the Governor of Kandahar opened fire at a meeting attended by the most senior US general in Afghanistan.
He was killed “within seconds” but not before fatally shooting police chief Lt Gen Abdul Raziq, a senior Afghan figure in the fight against the Taliban who had survived several assassination attempts.
US Brig Gen Jeffrey Smiley was shot, as was another American, but Gen Austin Miller, the commander of Nato’s Resolute Support Mission, was not hurt.
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.
Nangarhar, which shares a long and porous border with Pakistan, has long been a stronghold for ISIS in Afghanistan, although the Taliban also control 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 for counter-terrorism operations.
Washington's peace envoy Zalmay Khalilzad has been meeting Taliban representatives in Qatar in recent weeks, continuing a months-long effort to reach a peace deal.
Mr Khalilzad is seeking an agreement that eases fighting and leads to peace talks between the Taliban and Afghan government.
US President Donald Trump referred the talks in his State of the Union address on Tuesday, saying US soldiers were not meant to serve as law enforcement agencies for other nations.
"In Afghanistan, the determination and valour of our war fighters has allowed us to make tremendous progress, and peace talks are now under way," Mr Trump said.