— Taliban insurgents beheaded 17 Afghans in a rebel-controlled area of southern Afghanistan, officials said Monday, and two NATO troops were killed by an Afghan soldier in the eastern part of the country.

The Afghans, two of them women, were killed Sunday night in the Kajaki area of Helmand province, where they were attending a party that featured music and mixed­gender dancing, provincial officials said. The radical Islamist Taliban movement, which enforced an extreme version of Islamic law during its 1996-2001 rule, prohibits such behavior.

President Hamid Karzai issued a statement condemning the “mass killing,” which he blamed on the Taliban, and ordering an investigation.

A Taliban spokesman denied that the group was involved and said local commanders in the area knew nothing about the killings, news agencies reported.

Neyamatullah Khan, chief of the Musa Qala district where U.S. Marines have long battled Taliban insurgents, said the Taliban slaughtered the partygoers as punishment for the celebration.

Daoud Ahmadi, a spokesman for the Helmand provincial government, said that all of the victims were beheaded but that it was not clear whether they had been shot first.

He later said the victims died when shooting broke out during a fight between two Taliban commanders over two women, who were among the dead, according to the Associated Press. He said it was unclear whether the music and dancing triggered the violence and whether the dead were all civilians or included some Taliban fighters, AP reported.

The killings of the two NATO troops occurred in a remote area of eastern Laghman province where the joint forces were on patrol, said Sarhadi Zwak, a spokesman for the provincial governor.

There were conflicting accounts of the shooting, and it was not immediately clear whether it was part of a spate of “insider” or “green-on-blue” attacks on foreign troops by their supposed Afghan allies.

“According to reports, the Afghan soldier killed two NATO forces during a verbal disagreement, and the assassin was later gunned down, too,” Zwak said in a telephone interview. He said he had no details about the cause of the dispute.

However, Noman Hatefi, a spokesman for the Afghan army corps in eastern Afghanistan, said the two NATO soldiers, whom he identified as Americans, were killed by accident, AP reported. Hatefi said the two were killed when an Afghan soldier fell and accidentally fired his weapon during an insurgent attack, AP said. He said the soldier tried to run away but was killed by a U.S. aircraft that had been called in to provide close air support, AP said.

The NATO-led International Security Assistance Force (ISAF) and Afghanistan’s Defense Ministry confirmed the killings but did not elaborate. They did not identify the nationality of the foreign troops, but most of those stationed in the east are Americans.

The deaths bring to 12 the number of foreign troops killed this month, mostly on joint bases, by Afghan military men. Most of the slain foreign troops have been Americans.

The rise of insider attacks this year, unprecedented during the nearly 11-year U.S.-led war, forced NATO recently to order soldiers to carry loaded weapons at all times.

An ISAF spokesman estimated Monday that a quarter of the attacks stemmed from the infiltration of Taliban insurgents into the Afghan forces but that the majority of them had other roots.

The attacks come as NATO and U.S. forces continue to transfer security responsibilities to Afghan forces ahead of their planned withdrawal of all combat troops by the end of 2014.

Although insider attacks have largely targeted foreign troops, Afghan forces in recent months have suffered losses from similar strikes.

The killings of the civilians and foreign soldiers were part of a wave of violence in recent days. Insurgents stormed an Afghan army post Sunday night in the Washir district of Helmand province, killing 10 soldiers, officials said.

Eleven attackers were also killed in the gun battle, which continued for hours in the arid and remote district, the Defense Ministry said.

Javed Hamdard contributed to this report.

Javed Hamdard contributed to this report.