KUNDUZ, Afghanistan (Reuters) - Dozens of Afghan civilians were killed on Thursday in air strikes called in when U.S. and local troops came under heavy fire during an operation in the north of the country in which two American service members also died.

Afghan officials said there was heavy fighting overnight in the village of Buz Kandahari, about 5 km (3 miles) from the center of the city of Kunduz, which Afghan Taliban fighters succeeded in entering as recently as last month.

Air strikes called in to protect U.S. and Afghan special forces conducting the operation caused heavy casualties.

“Unfortunately more than 30 civilians, including women and children, were killed during the fighting. This was a horrible incident,” said Asadullah Amarkhil, the governor of Kunduz, adding that dozens had been wounded.

There were angry protests by civilians who brought the bodies of many of the dead into Kunduz, which saw major battles in early October.

“These bodies you see here are either children or women, they are not Taliban. All innocent children and women killed here - look at the bodies there,” said Gull Ahmad, pointing to the bodies of relatives who were killed in the strikes.

In a statement, the U.S. military said the troops came under attack while working with Afghan partners to clear a Taliban militant position and disrupt the group’s operations in the district around the city.

“As part of an Afghan operation, friendly forces received direct fire and air strikes were conducted to defend themselves,” said Brigadier General Charles Cleveland, of the NATO-led Resolute Support mission.

“We take all allegations of civilian casualties very seriously.”

In a statement, the Taliban said American forces were involved in a raid to capture three militant fighters when they came under heavy fire. An air strike hit the village where the fighting was taking place, killing many civilians.

U.S. Secretary of Defense Ash Carter said he was “deeply saddened” to learn that two U.S. service members had been killed and four injured in Afghanistan.

“Our service members were doing their part to help the Afghans secure their own country while protecting our homeland from those who would do us harm,” he said in a statement.

According to Pentagon data, 1,832 other U.S. service members have been killed in action in Afghanistan since 2001, when U.S.-backed forces toppled the Taliban regime.

KUNDUZ SECURITY IN PERIL

The violence underlines the precarious security situation around Kunduz, which Taliban fighters came close to over-running last month, a year after briefly capturing it in their biggest success of the 15-year-long war.

While the city itself was secured, the insurgents control large surrounding areas.

The U.S. military gave no details of the identity of the two personnel killed, their units or the circumstances of their deaths.

Although U.S. combat operations against the Taliban largely ended in 2014, special forces units have repeatedly engaged in fighting while assisting Afghan troops.

Masoom Hashemi, deputy police chief in Kunduz province, said police were checking if any of the dead had Taliban links.

Thousands of U.S. soldiers remain in Afghanistan as part of the Resolute Support training and assistance mission and a separate counterterrorism mission.

The deaths come a month after another U.S. service member was killed on an operation against Islamic State fighters in the eastern province of Nangarhar.

Afghan forces, fighting largely on their own since the international combat mission ended, have suffered thousands of casualties, with more than 5,500 killed in the first eight months of 2016.