Gunmen stormed an office of the Save the Children aid agency in Afghanistan's eastern city of Jalalabad on Wednesday and battled security forces all day with at least five people killed and 24 wounded before the attack was finally suppressed.
Islamic State claimed responsibility for the attack, which began with a suicide car bomb outside the office in the morning and continued as gunmen entered the compound where they resisted Afghan security forces for about 10 hours.
Plumes of black smoke rose from the area as the gunmen battled special forces through the afternoon. Up to 45 people who had taken refuge in a fortified "safe room" in the compound, were rescued by late afternoon, but fighting continued until after dark when officials said the last attacker was killed.
"The fight is over," the provincial governor's spokesman, Attaullah Khogyani told reporters.
Authorities said they believed six attackers were involved. Witnesses said at least some of them were in police uniform, a commonly used tactic.
Two of the dead were guards at the compound, and one was a civilian. It was not clear if the other two dead were attackers or civilians, the spokesman said.
The raid began with a huge blast at around 9 a.m. that rocked the neighbourhood, where other aid groups and government buildings are based.
"Right after that children and people started running away," said Ghulam Nabi, who was nearby when the bomb exploded. "I saw a vehicle catch fire and then a gunfight started."
Islamic State said the attack targeted British, Swedish and Afghan government institutions in a statement on its Amaq news agency. Save the Children was founded in Britain, and a Swedish aid group office and a building of the Afghan Department of Women's Affairs are near the compound.
The attack underlines how difficult operating in Afghanistan has become for humanitarian aid groups, which have faced heavy pressure from armed groups and kidnappers. In 2017, a total of 17 aid workers were killed and 32 injured in the country.
Save the Children, which says it reaches almost 1.4 million children in Afghanistan, said it had suspended its operations temporarily and closed its offices in Afghanistan, where it works in eight provinces as well as in three others through partnership agreements.
"We remain committed to resuming our operations and lifesaving work as quickly as possible, as soon as we can be assured that it is safe to do so," a group representative said in an emailed statement.
In October, the Red Cross said it was drastically reducing operations in Afghanistan following attacks that killed seven of its staff.
"An attack against an organisation that helps children is outrageous. Civilians and aid workers must not be targeted," said Monica Zanarelli, head of the Red Cross delegation in Afghanistan, in response to Wednesday's attack.
"Increased violence has made operating in Afghanistan increasingly difficult for many organisations."
President Ashraf Ghani, whose government has been under heavy pressure to improve security, also condemned the attack in a statement in which he called on neighbouring countries not to help militant groups.
Jalalabad is the capital of Nangarhar province on the porous border with Pakistan. The province has become a stronghold of Islamic State, which has grown into one of Afghanistan's most dangerous militant groups since it appeared around the beginning of 2015.
Backed by intensive U.S. air strikes, Afghan forces have claimed growing success against the Taliban and other militant groups, including Islamic State, but militant attacks on civilian targets have continued, causing heavy casualties.
The attack in Jalalabad came just days after Taliban militants attacked the Hotel Intercontinental in the capital, Kabul, killing at least 20 people, including 13 foreigners.