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

An American service member was killed and seven others were wounded by an Afghan soldier during a shootout that followed a visit from a high-ranking delegation of U.S. officials in Afghanistan on Wednesday.

U.S. defense officials told NBC News that American troops subsequently killed the gunman.

“We are aware that there was an exchange of gunfire involving Resolute Support service members near the provincial governor's compound in Jalalabad," U.S. Embassy spokeswoman Monica Cummings told NBC News, referring to the NATO mission in Afghanistan. "The incident took place after a senior U.S. official held a meeting with the provincial governor."

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

The top official who had been visiting was Ambassador Donald Yamamoto, who's serving as a political adviser to the American military in Afghanistan, U.S. officials told NBC News. He had left the scene before the shooting happened, they added.

The U.S. Embassy in Kabul earlier denied initial reports that Ambassador Michael McKinley, the current American envoy to Afghanistan, had been on the trip.

Provincial police chief Gen. Fazel Ahmad Shirzad told NBC News that the shootout happened after a meeting between U.S. and NATO officials, and Afghan tribal and community leaders.

He added: "After the meeting was concluded, the guests who flew from Kabul on a helicopter flew back. The members of coalition forces from Jalalabad airbase who had attended the meeting were preparing to convoy back to the base when an Afghan army soldier who was part of the original convoy escorting coalition forces to the meeting opened fire."

The frequency of such so-called insider attacks has fallen sharply this year as most foreign forces withdrew from the Afghanistan in 2014.

— Jim Miklaszewski, Fazul Rahim and F. Brinley Bruton

Reuters contributed to this report.