Afghan forces under Taliban fire asked for the US air strike that killed 22 people at a hospital in Kunduz, the US commander in Afghanistan said.

The US military had previously reported that its own troops were under fire and had called in the strike, which was carried out by an AC-130 gunship.

"We have now learned that on October 3, Afghan forces advised that they were taking fire from enemy positions and asked for air support from US air forces," General John Campbell told reporters.

"An air strike was then called to eliminate the Taliban threat and several civilians were accidentally struck," he said.

He said the request was made to US special forces who were advising the Afghans, but it was unclear how close to the action they were.

General Campbell criticised the Taliban for fighting from within urban areas and putting civilians at risk.

Fires burn in part of the Medecins Sans Frontieres hospital after it was hit by an air strike on October 3 ( AFP: MSF )

The general, who commands US forces in Afghanistan, declined to comment on the rules under which the US forces were operating.

But he promised a thorough and transparent investigation: "If errors were committed, we'll acknowledge them. We'll hold those responsible accountable, and we'll take steps to ensure mistakes are not repeated."

US Army Brigadier General Richard Kim is the senior investigator on the incident and is in Kunduz now, he added.

Sorry, this video has expired MSF's international president calls for thorough investigation into "unforgiveable violation of human rights".

Doctors Without Borders (MSF), which has since closed a trauma centre it was operating at the hospital, has called for an independent investigation "under the clear presumption that a war crime has been committed".

The charity said that despite frantic calls to military officials in Kabul and Washington, the main building housing the intensive care unit and emergency rooms was "repeatedly, very precisely" hit almost every 15 minutes for more than an hour.

Joanne Liu, the international president of MSF, told the ABC's The World program: "We are very concerned to let this pass without having a thorough investigation. Because it is actually a clear, inexcusable, unforgiveable violation of humanitarian rights."

"And this needs to be reiterated, otherwise in the 63 different countries where MSF today is working, we would not have anymore the sort of immunity we always thought we had."

The US General said there would be US, NATO, and Afghan investigations into the strike.

"If there's other investigations out there that need to go on, we'll make sure to coordinate those as well," he said, adding that a preliminary report on the incident was expected "very shortly, in the next couple of days."

The attack on the hospital was carried out by an American AC-130 gunship ( US Air Force )

ABC/wires