Two US soldiers have been killed and six others wounded when an individual in an Afghan army uniform opened fire on them with a machinegun in eastern Afghanistan, the US military said.
The incident, which took place in Nangarhar province, occurred after a combined US and Afghan force completed a "key-leader engagement" at a base in Sherzad district, Colonel Sonny Leggett, a spokesman for US forces in Afghanistan, said in a statement on Saturday.
"Current reports indicate an individual in an Afghan uniform opened fire on the combined US and Afghan force with a machine gun," Leggett said, adding that the cause or motive behind the attack were not immediately known.
In a tweet, the US Army's 7th Special Forces Group (Airborne) said "several" of its soldiers had been killed or injured during combat operations in Afghanistan.
No group immediately claimed responsibility for the incident.
Provincial governor Shah Mahmood Meyakhil said in an audio message to reporters that three Afghan commandos were wounded.
He said it was not immediately clear if the incident was a deliberate act by an "infiltrator" or an accident. "It was not a clash between the forces. We are investigating," Meyakhil said.
Insider attacks, often known as "green-on-blue" attacks, have been a regular feature of the conflict in Afghanistan, although their frequency has diminished in recent years.
About 13,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 counterterrorism operations.
The incident came at a delicate time in the 18-year war, as US diplomats have been talking with the Taliban for months to agree on a timetable for the withdrawal of foreign forces in exchange for security guarantees.
US special envoy Zalmay Khalilzad has been negotiating with the Taliban for about 18 months for a deal that would see the Pentagon pull its troops from Afghanistan.
In return, the Taliban would guarantee the country is not used as a safe haven to launch attacks on other countries.
Many are sceptical of the proposed deal and US President Donald Trump himself declared talks "dead" in September amid continued Taliban violence. Negotiations have since resumed in Qatar.
Trump has expressed his eagerness to bring troops home and end the longest conflict in US history.