The apparent insider attack, which took place in Nangarhar province, occurred after a combined US and Afghan force was returning from a "key-leader engagement," Colonel Sonny Leggett, a spokesman for US forces in Afghanistan, said in a statement.
Two US service members were killed and six others injured when an individual in an Afghan uniform opened fire on them, the US military said on Saturday.
The incident, which took place in Nangarhar province, occurred after a combined US and Afghan force was returning from a "key-leader engagement," Colonel Sonny Leggett, a spokesman for US forces in Afghanistan, said in a statement.
"We are still collecting information and the cause or motive behind the attack is unknown at this time," Leggett added.
Nangarhar Provincial Council member Ajmal Omer told The Associated Press the gunman was killed.
It wasn't immediately clear if the gunman was an insurgent infiltrator or rogue Afghan military personnel.
There have been numerous attacks by Afghan national army soldiers on their allied partners over the 18 years since the US invaded Afghanistan in the aftermath of the September 11, 2001 attacks.
Omer is a member of the provincial council and from Nangarhar province's Sherzad district, where he said the incident took place. An Afghan soldier was wounded, Omer said, without saying whether the wounded soldier had been involved in the shootings.
The Taliban and a Deash affiliate both operate in eastern Nangarhar.
Last July, two US service members were killed by an Afghan soldier in the southern Kandahar province.
The shooter was wounded and arrested.
In September, three US military personnel were wounded when an member of the Afghan Civil Order Police fired on a military convoy, also in Kandahar.
The incident came as Washington has sought to find an end to the war in Afghanistan.
Washington's peace envoy Zalmay Khalilzad has been meeting with Taliban representatives in the Middle Eastern state of Qatar in recent weeks.
He's seeking an agreement to reduce hostilities to get a peace deal signed that would start negotiations among Afghans on both sides of the conflict.
In his State of the Union Address on Tuesday, President Donald Trump referenced the peace talks, saying US soldiers were not meant to serve as “law enforcement agencies” for other nations.
“In Afghanistan, the determination and valor of our war fighters has allowed us to make tremendous progress, and peace talks are now underway, " he said.