US airstrikes early Thursday killed at least 30 Afghan civilians, including women and children, in the volatile northern province of Kunduz, officials said, after a Taliban assault left two American soldiers dead.
The airstrike triggered emotionally-charged protests in the provincial capital, with the victims' relatives parading mutilated bodies of dead children piled into open trucks through the streets of Kunduz city.
The carnage underscores worsening insecurity after the Taliban last month overran Kunduz city for the second time in a year, as NATO-backed Afghan forces struggle to rein in the insurgents.
Afghan forces and coalition troops were conducting a joint operation against the Taliban on the outskirts of the city when they came under insurgent fire, prompting calls for air support.
"In the bombardment 30 Afghan civilians were martyred and 25 others were wounded," provincial spokesman Mahmood Danish told AFP.
Police spokesman Mahmoodullah Akbari gave the same toll to AFP, adding that the dead included infants aged as young as three months and other children.
"They were asleep when their house came under attack by coalition troops," Akbari said.
In a brief statement on Twitter, NATO conceded that US forces were behind the airstrike.
"Airstrikes were conducted in Kunduz to defend friendly forces under fire. All civilian casualty claims will be investigated," it said.
Taza Gul, a 55-year-old laborer, was among dozens of angry protesters outside the Kunduz governor's office, bringing with him the bodies of seven dead family members in a motorized tricycle.
"I am devastated. I want to know, why these innocent children were killed. Were they Taliban?" said Gul. "No, they were innocent children."
Civilian caused by NATO forces have been one of the most contentious issues in the 15-year campaign against the insurgents, prompting strong public and government criticism.
Afghan President Ashraf Ghani said he was "deeply saddened" by the killings, while urging the military to do everything possible to prevent civilian casualties.
"The enemies of Afghanistan's people use civilian houses in Kunduz as shields, resulting in the killing of a number of our countrymen, including women and children," the presidential palace said in a statement.
The strikes occurred after a firefight with insurgents killed two US soldiers and three Afghan special forces during an anti-Taliban operation in Kunduz.
The firefight erupted as American soldiers were assisting Afghan troops to clear a Taliban position and disrupt the group's operations, US forces said.
"On behalf of all of US Forces - Afghanistan, today's loss is heartbreaking and we offer our deepest condolences to the families and friends of our service members who lost their lives today," said John Nicholson, the top US and NATO commander in Afghanistan.
"Despite today's tragic event, we are steadfast in our commitment to help our Afghan partners defend their nation," he added, without disclosing the names of the dead soldiers.
The killings come just days before the US presidential election.
During three lengthy debates between presidential candidates Hillary Clinton and Donald Trump, Afghanistan got scarcely a passing mention -- even though the situation there will be an urgent matter for the new president.
Either one of them will inherit America's longest war with no end in sight.
The US military, which leads a NATO mission to train and assist local forces after their combat mission ended in 2014, often gives upbeat assessments about Afghan military performance.
But as Afghan military forces near the end of a second year leading security operations without full NATO assistance, they are sustaining heavy casualties.
The Taliban's apparent strategic goal in 2016 is to seize another provincial capital like they briefly did in Kunduz last year, in a stinging blow to Afghan forces.
They have launched multiple assaults in recent months including in Kunduz, Lashkar Gar in poppy-growing Helmand province and Tarinkot, the capital of Uruzgan province.
The worsening conflict has prompted US forces to step up airstrikes to support their struggling Afghan counterparts, fuelling the perception they are increasingly being drawn back into the conflict.