A drone strike in Kabul last month killed as many as 10 civilians, including seven children, the US military said on Friday, apologizing for what it called a "tragic mistake".
The Pentagon had said the Aug 29 strike targeted an Islamic State suicide bomber who posed an imminent threat to US-led troops at the airport as they completed the last stages of their withdrawal from Afghanistan.
Even as reports of civilian casualties emerged, the top US general had described the attack as "righteous".
The head of US Central Command, Marine Corps General Frank McKenzie, said that at the time he had been confident it averted an imminent threat to the forces at the airport.
"Our investigation now concludes that the strike was a tragic mistake," McKenzie told reporters.
He said he now believed it unlikely that those killed were members of the local Islamic State affiliate, ISIS-Khorasan, or posed a threat to US troops. The Pentagon was considering reparations, McKenzie said.
The killing of civilians, in a strike carried out by a drone based outside Afghanistan, has raised questions about the future of US counter-terrorism strikes in the country, where intelligence gathering has been all but choked off since last month's withdrawal.
And the confirmation of civilian deaths provides further fuel to critics of the chaotic US withdrawal and evacuation of Afghan allies, which has generated the biggest crisis yet for the Biden administration.
In a statement, Defense Secretary Lloyd Austin said the drone strike had killed a Mr Ahmadi who worked for a non-profit called Nutrition and Education International.
"We now know that there was no connection between Ahmadi and ISIS-Khorasan, that his activities on that day were completely harmless and not at all related to the imminent threat we believed we faced," Austin said in the statement.
"We apologize, and we will endeavor to learn from this horrible mistake."
While it is rare for senior Pentagon officials, including the defense secretary, to apologize personally for civilians killed in military strikes, the US military does publish reports on civilians killed in operations around the world.
Reports had emerged almost immediately that the drone strike in a neighborhood west of Kabul's Hamid Karzai International Airport had killed civilians including children. Video from the scene showed the wreckage of a car strewn around the courtyard of a building. A spokesperson for Afghanistan's new Taliban rulers, Zabihullah Mujahid, said at the time that the attack killed seven people, and that the Taliban was investigating.
The strike came three days after an Islamic State suicide bomber killed 13 US troops and scores of Afghan civilians who had crowded outside the airport gates, desperate to secure seats on evacuation flights, after US-trained Afghan forces melted away and the Taliban swept to power in the capital.
Following the suicide bombing at the airport, the US military launched a drone strike in eastern Afghanistan that it said killed two Islamic State militants. That strike is not under review.
The second, mistaken strike came as the US military was on heightened alert, with officials warning they expected more attacks on the airport, including from rockets and vehicle-borne explosive devices, as the Pentagon wrapped up its mission.
General Mark Milley, the chairman of the Joint Chiefs of Staff, appeared to blame the fog of war, even as he acknowledged in a statement that the civilian deaths were "heart wrenching".
"In a dynamic high threat environment, the commanders on the ground had the appropriate authority and had reasonable certainty that the target was valid," Milley said.
The authority to carry out strikes in Afghanistan - against al Qaeda or Islamic State - will not rest any more with US commanders in the region, a US defense official told Reuters, adding Austin himself will have to authorize any future strikes.
Still, the intelligence failure exposed in America's last military strike of its war in Afghanistan raises hard questions about the risks going forward. These include whether the United States can keep track of al Qaeda and Islamic State threats, and act quickly on any information it gets.
McKenzie played down the impact the latest civilian casualties would have on future actions in Afghanistan.
"I don't think you should draw any conclusions about our ability to strike in Afghanistan against ISIS-K targets in the future based on this particular strike," he said.