A heavily armed U.S. gunship designed to provide added firepower to Special Operations forces was responsible for shooting and killing 22 people at a Doctors Without Borders hospital in Kunduz, Afghanistan, over the weekend, Pentagon officials said Monday.

The attack occurred in the middle of the night Saturday, when Afghan troops and a U.S. Special Forces team training and advising them were on the ground near the hospital in Kunduz, the first major Afghan city to fall to the Taliban since the war began in 2001. The top U.S. general in Afghanistan said Monday the airstrike was requested by Afghan troops who had come under fire, contradicting earlier statements from Pentagon officials that the strike was ordered to protect U.S. forces on the ground.

The new details, and the continuing dispute over what exactly happened, heightened the controversy over the strike. In the two days since the incident, U.S. officials have struggled to explain how a U.S. aircraft wound up attacking a hospital run by Doctors Without Borders. On Monday, the medical humanitarian group said the United States was squarely responsible.

“The reality is the U.S. dropped those bombs,” Christopher Stokes, general director of Doctors Without Borders, said in a statement. “With such constant discrepancies in the U.S. and Afghan accounts of what happened, the need for a full transparent independent investigation is ever more critical.”

The weekend’s disastrous airstrike reinforces doubts about how effectively a limited U.S. force in Afghanistan can work with Afghan troops to repel the Taliban, which has been newly emboldened as the United States draws down its presence.

The strike also comes as the Obama administration is weighing whether to keep as many as 5,000 U.S. troops in Afghanistan beyond 2015, according to senior officials. Obama has not made a final decision on the proposal, but the recent advances by the Taliban have certainly complicated the president’s calculus.

Army Gen. John Campbell, commander of U.S. forces in Afghanistan, told reporters Monday at a news conference that Afghan forces “advised that they were taking fire from enemy positions and asked for air support from U.S. forces.” Campbell made it clear that this differed from initial reports that said U.S. forces were under attack and called in the airstrikes for their defense.

Campbell’s remarks differed from two previous comments, including one made by Secretary of Defense Ashton B. Carter on Sunday that said U.S. forces were under attack.

“At some point in the course of the events there [they] did report that they, themselves, were coming under attack. That much I think we can safely say,” Carter told reporters Sunday.

What the streets of Kunduz look like

A wounded staff member of Doctors Without Borders (MSF), (L), survivor of the US airstrikes on the MSF Hospital in Kunduz, receives treatment at the Italian aid organization, Emergency's hospital in Kabul on October 6, 2015. Afghan forces called in a US air strike on a Kunduz hospital that killed 22 people, the top American commander in Afghanistan said October 5, 2015, after medical charity MSF branded the incident a war crime. AFP PHOTO / Wakil KohsarWAKIL KOHSAR/AFP/Getty Images (Wakil Kohsar/AFP/Getty Images)

Abdul Qahar Aram, spokesman for the Afghan army’s 209th Corps in northern Afghanistan, said he could not comment on the specifics of Saturday’s hospital bombing. But Aram said there was a “strong possibility” that Afghan forces had requested it.

A spokesman for Afghan President Ashraf Ghani had no immediate comment on Campbell’s statement.

One aspect of the strike that remained unclear Monday was the exact role played by U.S. forces accompanying the Afghans that night.

After Kunduz was overrun with Taliban fighters late last month, American Special Operations forces were ferried in to shore up Afghan forces that were making little headway in the fight to retake the populated city center. Together, the U.S. and Afghan forces have been able to retake nearly all of the city.

These “train, advise and assist” missions are a staple of U.S. Special Forces capabilities and have been conducted extensively in recent years. In combat situations, rather than return fire, U.S. troops on these missions are more likely to help direct communication, casualty evacuation and direct air support from an AC-130, for instance, if it is available.

As a result, there has been little direct contact between U.S. troops and the Taliban since most U.S. forces were relegated to the sidelines when official combat operations ended last year.

The aircraft that carried out the weekend attack was an AC-130 gunship, according to Campbell. Unlike jets, the AC-130 is a unique aircraft dedicated almost entirely to supporting Special Operations forces.

In order to make sure targeting and communication from the ground to the aircraft is as seamless as possible, every AC-130 flies with a liaison officer who has spent time as a Special Forces soldier on the ground.

While most jets streak across a target, moving quickly while dropping bombs or firing cannons or machine guns, the AC-130 essentially loiters over a target at around 7,000 feet, flying in a circle and firing from weapons ports mounted on the aircraft’s left side.

Unlike other military fixed-wing aircraft, an AC-130 is requested differently. While a jet requires a map coordinate to engage its target, the AC-130 relies on direction (a compass heading) and a distance to the enemy target from the friendly forces engaged on the ground. In short, it relies on visual targeting.

This difference might explain why the hospital was targeted even though Doctors Without Borders said it had given U.S. and Afghan forces its map coordinates before.

“It’s a visual acuity aircraft,” said a U.S. close-air support pilot who spoke on the condition of anonymity because of his active-duty status. “An AC-130 finds the friendly force, then fires over their left or right shoulder.”

The pilot went on to add that an AC-130 does not enter enemy airspace and look for targets. It specifically has to be guided onto the target by a force on the ground and will fire only after identifying friendly and enemy forces, he said.

The aircraft, because of its large profile and the fact that it operates at low altitude, flies close air support missions only at night. Since it only works in the dark, the crew of roughly a dozen uses a number of infrared sensors and night vision devices to see and engage targets on the ground.

According to Navy Cmdr. Elissa Smith, a Pentagon spokeswoman, there have been 12 U.S. airstrikes around the city of Kunduz since Sep. 29. The airstrike on the Doctors Without Borders hospital was the second strike within the city.

It now ranks among one of the most high-profile U.S. strikes to result in civilian casualties in Afghanistan. In July 2002, a U.S. AC-130 fired on a wedding party, killing more than 40 and injuring more than 100 people in northern Helmand province.

Since Saturday’s attack, Doctors Without Borders has left Kunduz.

Tim Craig in Kabul contributed to this report.

Read more: