Zabihullah Mujahid, a Taliban spokesman, claimed responsibility for the bombing, which sent thick, black smoke into the sky from the site near the government's former Interior Ministry building. The force of the blast shattered windows of surrounding buildings while causing few low-rise structures to collapse.
Outside the hospital, people were carrying the injured on their backs and paramedics loaded several people into ambulances at once.
Kabul has been the site of numerous bombing attacks claimed by the Islamic State group and the Taliban over the previous year. "The building shook. All our windows broke".
"It is a massacre", said Dejan Panic, Afghan coordinator for the Italian aid group Emergency, which runs a nearby trauma hospital.
A man told Tolo News he was passing the area when the explosion happened. At least 11 people were wounded in the attack.
Mirwais Yasini, a member of parliament who was nearby when the explosion occurred, said the ambulance approached a checkpoint close to an office of the High Peace Council and several foreign embassies, and blew up.
India on Saturday strongly condemned the "barbaric and dastardly" terrorist attack in Kabul on the same day.
"It targeted our checkpoint".
The Health Ministry said 40 were killed and about 140 wounded.
Members of the European Union's delegation in Kabul were in their "safe room" and there were no casualties, an official told AFP.
Earlier this week on Tuesday, a raid by the Taliban on a high end hotel had killed atleast 20 people, including 13 foreigners.
A security alert issued to foreigners on Saturday morning had warned that the Islamic State group, which has terrorised the city in recent months, was planning "to conduct aggressive attacks" on supermarkets, shops and hotels frequented by foreigners.