The attack got under way when a suicide bomber detonated his explosives near the entrance of the hospital site.
Gunmen then broke into the hospital grounds, firing their weapons there, the Taliban said.
A Taliban security official, speaking to Reuters on condition of anonymity, said at least 25 people had been killed and more than 50 wounded in the attack. The Islamist group did not release an official casualty figure.
Other Taliban sources put the toll much lower, with a senior official telling AP only seven people had died.
The group did confirm that a senior Taliban commander, Mawlawi Hamdullah Mukhlis, head of the Kabul military corps and one of the first senior Taliban commanders to enter the abandoned presidential palace after the city fell on August 15, was killed in the attack.
The attack on the 400-bed Sardar Mohammad Daud Khan hospital, the country’s biggest military hospital, was a complex operation involving suicide bombers and gunmen.
Taliban spokesman Zabihullah Mujahid said the group’s special forces dropped into the site by helicopter and prevented the attackers from entering the hospital itself, with all killed at the entrance or in the courtyard.
Mujahi also said that two women and a child were among those killed in the attack, AFP reported.
Witnesses said at least two helicopters flew over the area as the assault went on, one of the first times Taliban forces have used aircraft captured from the ousted Western-backed government in a military operation.
Targeting hospitals
The assault on the hospital adds to a growing list of attacks and killings since the Taliban completed their victory over the former Afghan government in August, undermining their claim to have restored security to Afghanistan after decades of war.
The Taliban spent 20 years waging an insurgency against the US-backed Afghan government.
Now they face the struggle of bringing stability to Afghanistan, which has been hit in recent weeks by a series of bloody assaults claimed by IS-K.
The military hospital, which treats wounded soldiers from both the Taliban and former Afghan security forces, was previously attacked in 2017, when gunmen disguised as medical personnel killed at least 30 people in an hours-long siege.
Although both IS-K and the Taliban are hardline Sunni Islamist militants, they differ on details of religion and strategy.
IS-K have claimed four mass casualty attacks since the Taliban takeover on August 15, including suicide bomb blasts targeting Shiite Muslim mosques. The group regards Shiite Muslims as heretics.
In the 2017 attack on the military hospital, militants went room to room killing people, switching to knives when they ran out of ammunition.
The attack was claimed by IS-K, and the Taliban denied responsibility. However, survivors told AFP that the attackers chanted "Long live Taliban" in Pashto and attacked all but two wards on the hospital's first floor where Taliban patients were admitted.
Black smoke
An Italian NGO which runs a separate hospital in Kabul tweeted on Tuesday that it has received nine patients with injuries from the blast site.
Pictures shared on social media showed black smoke billowing into the air after the explosions, the first of which went off at around 1:00pm (0830 GMT).
AFP journalists saw Taliban fighters racing to the scene in at two armoured personnel carriers and pick-up trucks.
Roads close to the heavily fortified "Green Zone" where the buildings of several former Western embassies were located were closed off to traffic and Taliban guards scaled up searches.
Source: France 24