At least 19 people were killed and 50 more wounded in an attack on a military hospital in Kabul on Tuesday, the latest atrocity to rock Afghanistan since the Taliban seized power.
The Taliban's rivals, the Islamic State group, claimed responsibility for the gun and bomb assault in the centre of the capital.
Islamic State-Khorasan (IS-K) said in a statement on its Telegram channels that "five Islamic State group fighters carried out simultaneous coordinated attacks" on the sprawling site.
"The IS insurgents wanted to target civilians, doctors and patients in the hospital," Taliban spokesman Zabiullah Mujahid said, claiming that Taliban forces had repulsed the attack within 15 minutes.
As part of the response, he said, Taliban "special forces" were dropped onto the roof of the hospital from one of the helicopters that the group seized from Afghanistan's former US-backed government.
The attack got under way when a suicide bomber detonated his explosives near the facility's entrance. Gunmen then broke into the hospital grounds, firing their weapons.
"Nineteen dead bodies and about 50 wounded people have been taken to hospitals in Kabul," a health ministry official who asked not to be named told AFP.
Mujahid played down the death toll, but confirmed that two Taliban fighters, two women and a child had been killed outside the hospital.
One woman who had been trapped in the hospital when the attack began told AFP how she and her friend "felt we were going to die, that our lives were ending".
"There was a blast at the door," Rowana Dawari, a poet and lecturer, told AFP.
"Daesh came and started firing, we were stuck. We heard firing, glass breaking. We locked ourselves in a bathroom," she said, referring to IS by its local name.
"Later, Taliban came and we saw they were with our doctors, so we knew it was OK."
Amanudhin, a 28-year-old cleaner at the hospital, pushed an elderly, frail and partially sighted patient, Mariam, away from the scene in a wheelchair.
"The explosion happened and after a while people started screaming 'Daesh is here'," he told AFP. "We heard a lot of firing.
"We were in the 7th floor and locked ourselves in a room. There were injured people everywhere. Broken glass."
They hid until Taliban fighters came to rescue them: "They were special forces, professionals, they broke the door and got inside."
Going 'room to room'
The Taliban spent 20 years waging an insurgency against the ousted US-backed 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 the Islamic State group's local chapter.
"All the attackers are dead. The attack was initiated by a suicide bomber on a motorcycle who blew himself up at the entrance of the hospital," a Taliban official from the government media team said.
Two explosions targeted the hospital area, he had earlier said in a statement.
AFP staff in the city heard a second explosion some 30 minutes after the first was reported.
"I heard a big explosion coming from the first checkpoint. We were told to go to safe rooms. I also hear guns firing," a doctor at the Sardar Mohammad Daud Khan hospital told AFP while the attack was being carried out.
"I can still hear gun firing inside the hospital building. I think the attackers are going from room to room... like the first time it was attacked," the doctor added.
Ambulances speeding through Kabul
The 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 and the Taliban are hardline Sunni Islamist militants, they differ on details of religion and strategy.
IS 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.
The 2017 attack was also claimed by the Islamic State group, and the Taliban denied responsibility.
Pictures shared on social media on Tuesday showed black smoke billowing into the air after the explosions, the first of which went off at around 1:00 pm (0830 GMT).
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.
The US State Department condemned the attack, spokesman Ned Price said in a tweet Tuesday evening.
"We mourn those killed and offer our condolences to their loved ones," he said. "Targeting medical professionals and patients is abhorrent and has no justification."