Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Two U.S. troops were killed and six others wounded in an attack Saturday in Nangarhar Province, Afghanistan, a military official said.

U.S. and Afghan forces were conducting a joint operation when an individual wearing an Afghan uniform opened fire on the service members using a machine gun, according to Col. Sonny Leggett, spokesman for American forces in Afghanistan.

"We are still collecting information and the cause or motive behind the attack is unknown at this time," Leggett said in a statement. "The incident is under investigation."

The Pentagon on Sunday the servicemen who were killed as Sgt. 1st Class Javier Jaguar Gutierrez, 28, and Sgt. 1st Class Antonio Rey Rodriguez, 28.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Gutierrez was from San Antonio, Texas, and Rodriguez was from Las Cruces, New Mexico. Both men were assigned to the 3rd Battalion, 7th Special Forces Group out of Eglin Air Force Base, Florida.

Download the NBC News app for breaking news and politics

A spokesperson for the Afghan Ministry of Defense said a "high level" delegation was investigating the incident.

They added that attacks like this did not have "negative effects on the friendship and spirit of cooperation," between Afghan forces and their U.S. counterparts.

"We will continue our fight against terrorism together," they said.

The U.S. has 12,000 to 13,000 troops in Afghanistan, but in December three current and former U.S. officials told NBC News that the Trump administration was poised to withdraw approximately 4,000 of them.

President Donald Trump has repeatedly pledged to end the “endless wars" and NBC News reported in August that the president has made clear to his advisers that he wants to pull all U.S. troops out of Afghanistan by the 2020 election, according to five current and former administration and military officials.

The war in Afghanistan, America's longest, has raged for 18 years and killed nearly 2,300 troops, according to the Department of Defense.

From January 2009, when the United Nations began a systematic documentation of civilian casualties, to September, some 34,000 Afghan civilians have been killed as a result of the armed conflict.