The US strike was launched in support of Afghan security forces who had confronted militants after they fired a volley of rockets near the capital’s international airport hours after Mattis arrived in the country for talks.
One person was killed and 11 others were wounded in the assault, according to the interior ministry. The Taliban and the Islamic State’s local Khorasan province affiliate claimed responsibility.
“Tragically, one of the missiles malfunctioned, causing several casualties,” NATO’s Resolute Support mission said in a statement.
NATO said it “deeply regrets the harm to non-combatants” and an investigation was under way into the attack and the defective ammunition.
The casualties caused by a US airstrike in the capital have cast a pall over Mattis’s trip to the country and could fuel anger towards American forces whose reputation is already tarnished.
Earlier this month US forces distributed leaflets in the northern province of Parwan that were deemed highly offensive to Muslims and sparked angry protests.
Mattis is the first member of US President Donald Trump’s cabinet to visit Afghanistan since Trump last month pledged to stay the course in America’s longest war.
His unannounced visit came as the country’s beleaguered security forces struggle to beat back the Taliban, which has been on the offensive since US-led NATO combat troops withdrew at the end of 2014.
Mattis, along with Stoltenberg, held talks with President Ashraf Ghani to discuss the US-led NATO “train and assist” mission — designed to strengthen Afghanistan’s military so it can defend the country on its own.
At a joint news conference with Ghani at the presidential palace, Mattis and Stoltenberg renewed their commitment to Afghanistan, and expressed determination to stop the country becoming a safe haven for terrorists.
“We will not abandon Afghanistan to a merciless enemy trying to kill its way to power,” Mattis told reporters in reference to the Taliban.
Stoltenberg said: “The more stable Afghanistan is the more safe we will be.”
So far, more than 15 NATO members have agreed to send additional troops.
US generals have for months been describing the situation in Afghanistan as a stalemate, despite years of support for Afghan partners, continued help from NATO and an overall cost in fighting and reconstruction to the United States of more than $1 trillion.
Wednesday’s succession of rocket attacks in Kabul did not alter Mattis’s movements, and he later flew to Forward Operating Base Gamberi east of Kabul, where he spoke to US troops who are training Afghan security forces.
October marks the war’s 16th anniversary, and the resurgent Taliban have promised to turn Afghanistan into a “graveyard” for foreign forces. They have been mounting deadly attacks as they maintain their grip on large swathes of the country.
On allegations that Iran and Russia are actively propping up the Taliban, Mattis said it would be “extremely unwise if they think they can somehow support terrorism in another country and not have it come back to haunt them”.
Under Trump’s plan, the US is sending more than 3,000 additional troops to Afghanistan, on top of the 11,000 already on the ground, to train and advise the country’s security forces.
NATO allies have about 5,000 troops deployed around the country.
Critics have questioned what the extra US soldiers can accomplish that previous forces — who numbered some 100,000 at the height of the fighting — were unable to do.
But Afghanistan expert John Hannah of the Washington-based Foundation for Defense of Democracies said the Afghan forces are now at adequate troop levels and have plenty of combat experience, boosting their chances of success.
We “may be getting to a point where after many more years of investment we’ve got an institutional (security force) capable of holding its own in most of the country against the Taliban and Al-Qaeda, and eventually grinding down the enemy and winding down the war,” Hannah told AFP.
“That, to my mind, is our main ticket out.”
General John Nicholson, head of US forces in Afghanistan, said the new US policy had lifted the spirits of Afghan troops while putting the Taliban leadership in “disarray” as they digest news of an indefinite US commitment.
“On the battlefield… Taliban morale has dipped, their casualties have remained very high,” Nicholson told reporters. “So this certainly has had an effect.”