KABUL -- Confusion reigned in the wake of the deadly bombing Saturday of a hospital compound in the northern Afghan city of Kunduz run by the international medical charity Doctors Without Borders, which killed at least 19 people and wounded dozens more. It remains unclear exactly who bombed the hospital and the charity has demanded an investigation into the incident.

Doctors Without Borders said that "all indications" pointed to the international military coalition as responsible for the bombing and called for an independent investigation. The U.S. Defence Secretary, Ash Carter said an inquiry is underway into whether the carnage at the clinic was caused by an airstrike from an American fighter jet, while Afghan officials said helicopter gunships had returned fire from Taliban fighters hiding in the compound.

The medical group, also known by the French acronym MSF, said its trauma centre "was hit several times during sustained bombing and was very badly damaged." At the time, the hospital had 105 patients and their caretakers, and more than 80 international and Afghan staff, it said. The charity did not say whether insurgents were present, and it was not immediately clear whether the staffers were killed by the Taliban, government or U.S. forces. The group said another 30 people were still missing after the incident.

The dead included 12 staffers and seven patients from the intensive care unit, among them three children, it said. A total of 37 people were injured, including 19 staff members, and 18 patients and caretakers. Five of the injured staff members were in critical condition, it said.

President Ashraf Ghani expressed his sorrow and said he and the commander of U.S. and NATO forces in Afghanistan, U.S. Army Gen. John Campbell had "agreed to launch a joint and thorough investigation."

U.N. Secretary-General Ban Ki-moon "strongly" condemned the airstrikes in Kunduz and said hospitals and medical personnel are "explicitly protected" under international humanitarian law, his spokesman's office said in a statement Saturday.

AP video of the compound showed burning buildings with firearms -- automatic rifles and at least one Russian-made machine-gun -- on the windowsills pointed outward.

Doctors Without Borders did not comment on the identities of the 30 missing people, but said all of its international staffers were alive and accounted for. It said it regularly updated its GPS co-ordinates with all parties to the conflict.

It said that from 2:08 a.m. to 3:15 a.m. Saturday, the hospital was hit by bombs at 15-minute intervals. It quoted Kunduz-based doctor Heman Nagarathnam saying that planes repeatedly circled overhead during that time.

"There was a pause, and then more bombs hit. This happened again and again. When I made it out from the office, the main hospital building was engulfed in flames," Nagarathnam said according to the MSF statement. "Those people that could, had moved quickly to the building's two bunkers to seek safety. But patients who were unable to escape burned to death as they lay in their beds."

Airstrikes have been a point of contention between Afghan authorities and the U.S. military throughout the 14 years since the Taliban's regime was ousted in a U.S. invasion in 2001. Kunduz has seen its share of mistaken bombings, notably in September 2009 when German forces called in a U.S. airstrike that killed more than 90 civilians.

Afghan forces backed by U.S. airstrikes have been battling the Taliban street-by-street in Kunduz since Thursday, to dislodge insurgents who seized the strategic city three days earlier in their biggest foray into a major urban area since the U.S.-led invasion of 2001. The insurgents have had the city encircled for months, and overran it in a surprise assault that embarrassed Ghani and called into question the competence of the U.S.-funded Afghan armed forces.

The confusion over the airstrike overshadowed reports of human rights abuses and widespread looting committed by the Taliban before they began their retreat, leaving behind a city without water or electricity, and rapidly dwindling food and medicine supplies as roads into Kunduz were mined by the insurgents to thwart the government assault.

Army Col. Brian Tribus, a spokesman for American forces in Afghanistan, said a U.S. airstrike on Kunduz at 2:15 a.m. "may have resulted in collateral damage to a nearby medical facility" and that the incident was under investigation. He said it was the 12th U.S. airstrike "in the Kunduz vicinity" since Tuesday.

The Ministry of Defence said "terrorists" armed with light and heavy weapons had entered the hospital compound and used "the buildings and the people inside as a shield" while firing on security forces. Brig. Gen. Dawlat Waziri, the ministry's deputy spokesman, told The Associated Press that helicopter gunships fired on the militants, causing damage to the buildings.

Interior Ministry spokesman Sediq Sediqqi said 10 to 15 "terrorists" had been hiding in the hospital at the time of the strike. "All of the terrorists were killed but we also lost doctors," he said. He said 80 staff members at the hospital, including 15 foreigners, had been taken to safety. He did not say what sort of strike had damaged the compound.

But Doctors Without Borders said "all indications currently point to the bombing being carried out by international coalition forces."

The attack was a "grave violation of international humanitarian law," it added. The MSF statement made no mention of whether Taliban fighters were present in the hospital.

The U.N. human rights chief Zeid Ra'ad Al Hussein said that if an investigation found the hospital was purposefully targeted, the incident could constitute a war crime.

Calling the incident "tragic, inexcusable and possibly even criminal," he said in a statement, "if established as deliberate in a court of law, an airstrike on a hospital may amount to a war crime."

Fighting raged throughout the day, and at around 2 p.m., the Taliban seized the medical compound, according to Sarwar Hussaini, the spokesman for the provincial police chief. "Fighting is continuing between Afghan security forces and the Taliban," he said.

Taliban spokesman Zabihullah Mujahid had earlier issued a statement saying there were no Taliban fighters in the hospital at the time of the bombing. He also accused Afghanistan's intelligence service of deliberately directing airstrikes on the hospital.

Doctors Without Borders, which operates in conflict zones across the globe, said it had treated 394 people wounded in fighting since the Taliban attacked the city. Afghan forces launched an operation to retake the city on Thursday, and the fighting has been underway since then.