KABUL, Afghanistan — Two United States soldiers were killed during a military operation in Afghanistan on Wednesday, bringing to nine the number of American military fatalities in the country this year.

The two, part of a Special Forces team, were killed by small-arms fire in southern Uruzgan province, American defense officials said. The soldiers were engaged in a fierce firefight with Taliban militants, with combatants only yards apart at one point, one of the defense officials said.

Earlier Wednesday, Zabihullah Mujahid, a Taliban spokesman, said the two service members had been killed in eastern Wardak Province. The reason for the difference in the reported location of the battle is unclear.

The deaths came just days before the resumption of talks between the Taliban and the United States. The new round is scheduled to start on Saturday in Doha, the Qatari capital.