KABUL, Afghanistan — An American employee of the C.I.A. was killed and a second American was wounded by an Afghan employee on the grounds of an annex to the United States Embassy here, officials in Washington said on Monday.

The gunman was killed, and the motive for the attack was being investigated, said Gavin Sundwall, a spokesman for the United Embassy in Kabul. The wounded American was evacuated to a military hospital for treatment.

The killing was followed by a barrage of gunfire from 9 p.m. to 9:30 p.m. on Sunday. People who were near the compound said they heard an explosion before the gunfire began.

The attack was on a building used by the Central Intelligence Agency in Kabul, according to several Western officials, and is near the presidential palace. American officials in Washington confirmed that the person killed in the attack worked for the C.I.A, but it was not clear what position the person held. The second American’s wounds were “not life-threatening,” the officials said.