BAGHDAD — Two U.S. service members were killed and nine others were wounded when a Kurdish Iraqi soldier sprayed them with gunfire inside an Iraqi army commando base north of Baghdad on Tuesday afternoon, Iraqi and U.S. military officials said.

The two Americans, whose names were being withheld until relatives are notified, were the first U.S. service members to be killed in Iraq since the Obama administration declared combat operations there officially over last week. The incident underscored the dangers still facing the nearly 50,000 U.S. troops still in the country.

Details remained murky. U.S. troops had escorted their commander to an afternoon meeting at an Iraqi army base in Tuz Khurmatu, 55 miles south of Kirkuk. During the meeting, a man in an Iraqi army uniform opened fire, the U.S. military said, adding that the assailant was shot dead at the scene.

It was unclear Tuesday whether the young shooter, whom Iraqi security officials identified as Soran Rahman Taleh Wali, a Kurdish member of one of the Iraqi army’s special forces units, had planned the attack. His commander said Wali was playing volleyball with U.S. troops inside the base when an argument escalated and Wali fired his weapon repeatedly.

“I’m not ruling anything out, but it seems pretty far-fetched that an altercation like this would be over a volleyball match,” said Maj. Lee Peters, a military spokesman for U.S. forces in the north of Iraq.

“We think this is an isolated incident, and it hasn’t broken our trust with the Iraqi security forces.”