Attackers targeted the 400-bed Sardar Daud Khan hospital starting with two massive explosions outside the building, officials said.
Gunmen then broke into the hospital grounds, witnesses said.
An affiliate of the Islamic State group, IS-K, later said it had carried out the attack.
Photographs and video footage from Kabul showed a plume of smoke over the area and recorded the sounds of gunfire. A doctor in the building told the AFP news agency he had been sent to seek shelter in a safe room during the attack and could hear guns being fired.