Afghan officials say a NATO air strike killed at least 30 civilians, including women, children and babies, in Kunduz.

At least 30 civilians, including women, children and babies, have been killed and dozens wounded in a NATO air strike in the northern province of Kunduz, Afghan officials have said.

The air raids on Thursday were in support of US and Afghan forces during an attack targeting senior Taliban commanders, according to provincial spokesman Mahmood Danish.

“Afghan forces and coalition troops conducted a joint operation against the Taliban insurgents. In the bombardment 30 Afghan civilians were martyred and 25 others were wounded,” Danish told AFP news agency.

Kunduz civilians told Al Jazeera the death toll was even higher than the figure given by officials.

READ MORE: Kunduz residents recall ordeal after Taliban attack

Afghan officials said on Thursday there had been heavy fighting overnight a few kilometres outside the Kunduz city centre, which Taliban fighters succeeded in entering last month before being driven out.

The target of the joint operation appeared to be two senior Taliban commanders killed in the fighting among 65 fighters, Kunduz police chief General Qasim Jangalbagh told AP news agency.

Al Jazeera’s Abdullah Shahood, reporting from Kabul, said that Afghan commandos, supported by NATO forces, descended from helicopters in two locations in Kunduz province, including in the village of Boze Qandahari, about 3km north of Kunduz city.

“The Afghan forces came under fire by the Taliban in the area and that’s when the air strikes were called in,” Shahood said .

“Most of these casualties are women and children, and they are as young as three months old.”

Dr Mohammad Naim Mangal, director of a hospital in Kunduz, said his facility received the bodies of a dead man and a child and treated 30 people, including children, wounded in the fighting.

The civilian deaths sparked angry protests among locals, with relatives rallying with the coffins of the victims to the governor’s office.

“They were chanting ‘Death to America’, ‘Death to President [Ashraf] Ghani” and they were [vowing] to take revenge,” Shahood said.

“Ordinary people were sleeping in their homes. The Taliban attacked Kunduz and then the bombs came … All night the airplanes were bombing,” a resident said.

“About 50 people died; 40 to 50 people were injured. What did those children do wrong? I want justice for the killers.”

‘Protecting friendly forces’

The US military said it had conducted the air strikes to protect “friendly forces” in an operation in which two American soldiers were killed.

“The service members came under fire during a train, advise and assist mission with our Afghan partners to clear a Taliban position and disrupt the group’s operations in Kunduz district,” the US military said in a statement.

In a separate statement, the NATO-led Resolute Support mission confirmed that air strikes had been carried out in Kunduz to defend “friendly forces under fire.

“All civilian casualty claims will be investigated,” it said.

OPINION: Afghanistan – Beyond reactive tactics and quick fixes

In a statement, the Taliban said American forces were involved in an operation to capture three fighters when they came under heavy fire.

The armed group also said that there were civilian casualties, while claiming Taliban fighters killed 16 US troops.

The Taliban often exaggerates its battlefield successes.

The deaths underline the precarious security situation around Kunduz, which Taliban fighters came close to over-running last month, a year after they briefly captured the city in their biggest success in the 15-year long war.

While the city itself was secured, the Taliban controls large areas of the surrounding province.

The US military gave no details on the identity of the two personnel who were killed, or what units they served with, and there was no immediate detailed comment on the circumstances of their deaths.

Although US combat operations against the Taliban largely ended in 2014, special forces units have been repeatedly engaged in fighting while providing assistance to Afghan troops.

Thousands of US soldiers remain in Afghanistan as part of the NATO-led Resolute Support training and assistance mission and a separate counterterrorism mission.

Afghan forces have suffered thousands of casualties, with more than 5,500 killed in the first eight months of 2016.

Last October, a US air stike hit a Doctors Without Borders (MSF) hospital in Kunduz, killing at least 42 people, including 24 patients, 14 staff and four caretakers.

At least 37 others were wounded in the raid, which destroyed the MSF hospital building and prompted widespread condemnation from human rights groups.

The US military said the air strike was a “mistake” and apologised, but insisted the attack was not a war crime .