KABUL, Afghanistan — Two boys out collecting firewood with their donkeys were killed by weapons fired from a NATO helicopter, Afghan and American military officials announced on Saturday.

The new U.S. commander in Afghanistan, Gen. Joseph F. Dunford Jr., promptly issued an apology and said the killings were an accident.

The victims, Toor Jan, 11, and Andul Wodood, 12, were brothers and had been walking behind their donkeys in the Shahed-e-Hasas district of Oruzgan province when the helicopter fired on them, according to Afghan officials in the district. The two donkeys were killed as well.

Dunford said that coalition forces had opened fire on what they thought were insurgent forces, and killed the boys by accident. “I offer my personal apology and condolences to the family of the boys who were killed,” Dunford said. “We take full responsibility for this tragedy.”

There was some disagreement about the presence of Taliban in the area and about the details of the episode.

Haji Mohammad Esmail, head of the district shura or council, said that the area was “fully under government control,” and that “we haven’t seen any engagement in the area and nor is the area threatened by the Taliban.”

Abdullah Himat, a spokesman for the provincial government in Oruzgan, in southern Afghanistan, said that while the shooting was a mistake, there had been Taliban presence in the area and insurgents had opened fire on the helicopter. Both Australian and American soldiers were involved in the episode, he said.

Fareed Ayal, the spokesman for the provincial police chief, said the helicopter was hunting for Taliban by tracking their radio signals when the killings took place. “There wasn’t any engagement with the Taliban, it was just a mistake that they have killed the two boys at an area where they thought they detected a Taliban radio signal,” he said.

The episode was the second air strike to kill civilians since Dunford assumed command in February. In Kunar province in eastern Afghanistan, up to 11 civilians were killed, including five children, when air strikes were used to destroy two homes.

That attack, which included Afghan forces on the ground, led President Hamid Karzai to forbid Afghan units from asking for air strikes by coalition air forces.