Medical aid group Doctors Without Borders — also known as Médecins Sans Frontières, or MSF — said on Sunday that the death toll from a suspected US airstrike on a hospital in Afghanistan has climbed to 22, with 12 MSF staff and 10 patients, including three children, killed in the attack.

The humanitarian organization issued a statement on Sunday denying that Taliban fighters were firing from its hospital in Kunduz at Afghan and NATO forces before the bombing, which also left dozens of people seriously wounded.

Fighting has continued to rage around the northern provincial capital of Kunduz for a seventh day as government forces backed by American air power seek to drive out Taliban militants who seized the city almost a week ago. Decomposing bodies littered the streets, and residents said that food was scarce.

The US military said it conducted an airstrike "in the vicinity" of the hospital, as it targeted Taliban insurgents who were directly firing on US military personnel. A US military spokesman acknowledged that the strike "may have resulted in collateral damage to a nearby medical facility."

The US-led military coalition in Afghanistan issued a statement on Sunday that said US forces conducted an airstrike at 2:15am local time on Saturday "against insurgents who were directly firing upon US service members advising and assisting Afghan Security Forces in the city of Kunduz."

The statement acknowledged that the strike "was conducted in the vicinity of a Doctors Without Borders medical facility," and said that NATO Resolute Support, the name of the current mission in Afghanistan, "has directed a preliminary multi-national investigation known as a Casualty Assessment Team." Results are expected "in a matter of days."

President Barack Obama said on Saturday that the Defense Department had ordered its own separate investigation into the incident, which the UN human rights chief said was "utterly tragic, inexcusable" and could amount to a war crime.

MSF issued a statement on Sunday demanding "a full and transparent investigation into the event be conducted by an independent international body," saying "an internal investigation by a party to the conflict would be wholly insufficient." MSF said it was operating "under the clear presumption that a war crime has been committed."

"Not a single member of our staff reported any fighting inside the MSF hospital compound prior to the US airstrike on Saturday morning," the statement said, noting that the facility was full of staff and patients. "We reiterate that the main hospital building, where medical personnel were caring for patients, was repeatedly and very precisely hit during each aerial raid, while the rest of the compound was left mostly untouched."

The bombing deals a blow to Afghan President Ashraf Ghani's policy of forging closer ties with the United States after his predecessor Hamid Karzai fell out with his backers in Washington in part over the number of civilians killed by bombs.

But the Afghan leader will be torn between distancing himself from Washington and the need for American firepower to help his forces drive insurgents out of Kunduz after the Taliban's biggest victory in the nearly 14-year-old war.

In a statement, Obama offered condolences to the victims of what he called "the tragic incident."

'The gates of the hospital compound were closed all night so no one that is not staff, a patient or a caretaker was inside the hospital when the bombing happened.'

"The Department of Defense has launched a full investigation, and we will await the results of that inquiry before making a definitive judgment as to the circumstances of this tragedy," Obama said.

In Kabul, the Afghan Ministry of Defense said Taliban fighters had attacked the hospital and were using the building "as a human shield." But the medical aid group denied this.

"The gates of the hospital compound were closed all night so no one that is not staff, a patient or a caretaker was inside the hospital when the bombing happened," MSF said in a statement on Sunday. "In any case, bombing a fully functioning hospital can never be justified."

Witnesses said patients were burned alive in the crowded hospital after the airstrike. Three children who were being treated in the hospital's intensive care unit were among the dead.

"We tried to take a look into one of the burning buildings," MSF nurse Lajos Zoltan Jecs said, recalling the bombing. "I cannot describe what was inside. There are no words for how terrible it was. In the Intensive Care Unit six patients were burning in their beds."

The MSF hospital that was a lifeline for thousands in the city said it was pulling most of its staff out of the area because the hospital was no longer functioning. Some staff had gone to help treat the wounded at other hospitals outside of Kunduz.

The struggle to retake Kunduz has raised questions over whether NATO-trained Afghan forces were ready to go it alone now most foreign combat troops have left. Afghan security forces were conducting house-to-house searches on Sunday, as gunbattles persisted in parts of the city, said Hamdullah Danishi, acting governor of Kunduz province.

Danishi said 480 Taliban fighters and 35 soldiers had been killed. The army raised the national flag in the central square, an area of the city that has changed hands several times in the fighting during the last week.

"Our security forces took control of strategic areas in Kunduz," Danishi said. "We have a clearance operation ongoing."

Afghan military helicopters on Sunday dropped 6,000 leaflets urging people to cooperate with the army, the defense ministry said. "If you see abandoned military vehicles or equipment anywhere turn them over to security forces," the leaflets read.

Corpses lay in the streets and people were too afraid to leave their homes, said one resident, Gulboddin. "You can hear the sound of gunfire all over the city," said Gulboddin, who, like many Afghans, has only one name. "Some of the bodies are decomposing."