Two US soldiers were killed and six wounded in a so-called insider attack in eastern Afghanistan's Nangarhar province late Saturday when an Afghan dressed in an Afghan army uniform opened fire, the US military said.

A member of the Nangarhar Provincial Council, Ajmal Omer, told The Associated Press the gunman was killed.

There have been numerous attacks by Afghan national army soldiers on their allied partners over the 18 years of Afghanistan's protracted war.

An Afghan defense ministry official, who was not identified because he was not authorized to speak to the media, said the shooter was an Afghan soldier who had argued with the U.S. forces before opening fire. He was not a Taliban infiltrator, the official said.

In a statement, the US military said 'an individual in an Afghan uniform opened fire on the combined US and Afghan force with a machine gun. We are still collecting information and the cause or motive behind the attack is unknown at this time.'

A US flag is seen at a military post in Deh Bala district of Nangarhar Province in eastern Afghanistan in this July 2018 file photo

The attack happened in the Nangarhar province in Afghanistan on Saturday, February 8

Omer, who is a member of the provincial council, is from Nangarhar province's Sherzad district, where he said the incident took place. An Afghan soldier was wounded, Omer said.

The US military said American and Afghan military personnel were fired on while conducting an operation in Afghanistan's eastern Nangarhar province.

The operation is to help the Afghan government clear the area of Taliban and insurgent forces.

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 U.S. 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 U.S. 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.

Earlier on Saturday, a tweet from 7th Special Forces group confirmed that soldiers were killed or injured in the incident and that the families of the deceased and wounded were being notified.

US military spokesman Col. Sonny Leggett said in a statement that both Afghan and US personnel were 'engaged by direct firing' as Newsweek reports two US fatalities

Early unverified claims by the Taliban indicated at least five dead US soldiers.

A senior Afghan defense official told Reuters it was not clear whether the incident was a result of clashes between Afghan and foreign forces or whether hardline Islamist militants were responsible for the attack.

'We are not ruling any possibility out but we are not calling it an insider attack, Taliban attack, or 'green-on-blue' at this stage,' said the official who requested anonymity.

Since the American invasion of Afghanistan, Taliban infiltrators have been a recurring problem in the Afghan Army.

The Taliban and the Islamic State group affiliate both operate in eastern Nangarhar province were the attack took place.

US soldier walks past burning trucks at the scene of a suicide attack at the Afghan-Pakistan border crossing in Nangarhar province, where two US soldiers may have died on Saturday (file photo)

This past December, 23 Afghan soldiers were killed when a Taliban infiltrator opened fire on his colleagues at a base in Ghazni Province in eastern Afghanistan.

The incident on Saturday comes as Washington seeks to find an end to Afghanistan's 18-year war, America's longest.

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.