Gunmen dressed as medics have stormed a hospital in the Afghan capital and battled security forces for hours, killing more than 30 people and wounding more than 50 in an attack claimed by Islamic State.
A suicide bomber blew himself up at the rear of the 400-bed Sardar Mohammad Daud Khan hospital, across the road from the heavily fortified US embassy, and three attackers with automatic weapons and hand grenades entered the complex.
Defence Ministry spokesman Dawlat Waziri said the attack was suppressed by mid-afternoon, with all three gunmen killed.
The gunmen, dressed as medical personnel, had taken up positions on the upper floors of the hospital and engaged special forces sent to the scene.
Security forces blocked off the area around the hospital, near a busy traffic intersection, and special forces soldiers descended on to the roof of the main building from helicopters.
Sporadic gunfire could be heard for hours and, as fighting went on, there was a second explosion, which a spokesman said was caused when a car inside the hospital complex blew up.
A statement from Islamic State's Amaq News Agency said its fighters had attacked the hospital, while an Afghan Taliban spokesman denied responsibility, saying the Islamist insurgency had "no connection" with the attack.
The raid on the hospital followed warnings by government officials that high-profile attacks in Kabul were likely to escalate this year.
With US President Donald Trump yet to announce his policy for Afghanistan, where the top US commander has said thousands more international troops may be needed to maintain stability, the attack also pointed to Islamic State's growing threat.
The movement, opposed to both the Western-backed government in Kabul and the Taliban, is based in the Middle East but has established a solid presence on the border with Pakistan.
It has also mounted several high-profile attacks on civilians in Kabul over the past year, including several on prominent Shi'ite targets.
The attack on a hospital that treats military casualties from around Afghanistan drew wide condemnation and President Ashraf Ghani said it "trampled on all human values".
"In all religions, a hospital is regarded as an immune site and attacking it is attacking the whole of Afghanistan," he said.
The attack came just a week after dozens of people were killed and wounded in co-ordinated attacks on a police station and an office of the intelligence service in Kabul.