Medical charity Medecins Sans Frontieres has condemned "in the strongest possible terms" deadly air strikes on its hospital in the Afghan city of Kunduz.
MSF said at least 12 of its staff and seven patients, three of them children, were killed in the attack.
It said the strikes had continued for more than 30 minutes after US and Nato officials were told of its location.
US forces were carrying out air strikes at the time.
Afghan President Ashraf Ghani said the Nato force in his country had apologised for the bombing of the hospital. The Nato alliance has admitted its forces may have hit the hospital.
At least 37 people were seriously injured, 19 of them MSF staff.
MSF says that all parties to the conflict, including Kabul and Washington, had been told the precise GPS co-ordinates of the hospital in Kunduz on many occasions, including on 29 September.
After staff at the hospital became aware of the aerial bombardment in the early hours of Saturday morning, US and Afghan military officials were again informed, MSF said.
Reuters news agency quotes an MSF official as saying that frantic staff phoned military officials at Nato in Kabul and Washington as bombs landed on the hospital for nearly an hour.
The official said the first bomb had landed at 02:10, and MSF staff called Nato in Kabul at 02:19 and military officials in Washington a few minutes later, but the bombing continued until 03:13.
A spokesman for US forces in Afghanistan, Col Brian Tribus, said: "US forces conducted an air strike in Kunduz city at 02:15 (local time)... against individuals threatening the force.
"The strike may have resulted in collateral damage to a nearby medical facility."
In a statement, US Defence Secretary Ash Carter said: "While we are still trying to determine exactly what happened, I want to extend my thoughts and prayers to everyone affected.
"A full investigation into the tragic incident is under way in co-ordination with the Afghan government."
Read more on the battle for Kunduz:
- The significance of Kunduz lies in its strategic location at the centre of drug-smuggling routes
- Residents' tales of fighting in Kunduz
- In pictures: How Kunduz 'recapture' unfolded
- Crucial capture: Taliban's biggest victory since 2001
- Who are the Taliban? A guide to the complexities and conflicts within the militant group
- Taliban selfies: The militants posing for pictures as they seized the city
The Afghan interior ministry said a group of 10 to 15 militants were found hiding in the hospital.
"They are killed, all of the terrorists were killed, but we also lost doctors," ministry spokesman Sediq Sediqi said.
The Taliban denied that any of its fighters were there.
A Taliban statement described the air strikes which hit the hospital as "deliberate", and carried out by "the barbaric American forces".
UN High Commissioner for Human Rights Zeid Ra'ad Al Hussein called for a swift, full and transparent investigation into the incident.
"This event is utterly tragic, inexcusable, and possibly even criminal," he said.
"International and Afghan military planners have an obligation to respect and protect civilians at all times, and medical facilities and personnel are the object of a special protection. These obligations apply no matter whose air force is involved, and irrespective of the location."
The International Committee of the Red Cross (ICRC) also strongly condemned the bombing.
"Such attacks against health workers and facilities undermine the capacity of humanitarian organisations to assist the Afghan people at a time when they most urgently need it," said Jean-Nicolas Marti, head of the ICRC delegation in Afghanistan.
MSF says that staff and patients critically injured in the attack on the hospital have been transferred to a hospital in Pul-e Khumri, two hours' drive away.
There has been intense fighting in Kunduz since Taliban fighters swept into the northern city on Monday.
Afghan officials said the government had regained control of Kunduz on Friday, but the Taliban denied the city had been retaken. Residents say many people are afraid to leave their homes.
US air power has been supporting Afghan government forces' efforts to regain the city.
In Badakhshan province, to the east of Kunduz, the Taliban have captured two districts in the past two days. The US embassy in Kabul has advised its citizens to leave the province.
Kunduz, with a population of around 300,000, is one of Afghanistan's largest cities and strategically important both as a transport hub and a bread-basket for the region.
The US-led Nato combat mission in Afghanistan ended in December 2014, but Nato forces remain for training and support purposes.
Nato's Resolute Support Mission, which was launched in January 2015, consists of more than 13,000 troops from 42 countries. The US contributes around half of these.