A man wearing an Afghan military uniform killed a U.S. service member and an American civilian outside the capital city of Kabul on Wednesday, officials said.

The incident occurred at Camp Morehead, a U.S. special forces base, a U.S. defense official told Fox News. It was described as an “inside the wire” incident.

A NATO statement said another U.S. service member and two U.S. civilians were wounded in the attack and were in a stable condition. A defense official told Fox News the shooter opened fire at the entrance to the base, where he was later killed.

"Anytime we lose a member of our team, it is deeply painful," the statement quoted General John W. Nicholson, Commander of U.S. Forces-Afghanistan. "Our sympathies go out to the families, loved ones, and the units of those involved in this incident."

The Afghan defense ministry launched an investigation into the incident, Dawlat Waziri, spokesman for the Afghan defense ministry, told reporters.

The victims were conducting duties as part of the larger NATO mission to train and advise the Afghan security services, and an investigation was being conducted to determine the exact circumstances of the incident.

A roadside bomb wounded two U.S. Army soldiers earlier this month in eastern Afghanistan.

In May, two Romanian soldiers were shot and killed when two Afghan army recruits opened fire on them in southern Kandahar province. Both attackers were later killed by other troops in a military comp.

Fox News' Lucas Tomlinson and The Associated Press contributed to this report.