The Islamic State group attacked a prison in eastern Afghanistan holding hundreds of its members, leading to an hours-long battle that saw the military retake control of the facility even as militants continued to fire on them from a nearby neighbourhood.
The fighting killed at least 29 people and wounded 50, authorities said.
Security forces seized the prison on Monday afternoon in Jalalabad, the capital of Nangarhar province, some 70 miles east of Kabul, Defence Ministry spokesman Fawad Aman said.
Sporadic gunfire rang out from nearby residential buildings in central Jalalabad, an area of high security near the provincial governor’s office.
The attack highlighted the challenges ahead for Afghanistan, even as US and Nato forces begin to withdraw following America striking a peace deal with the Taliban.
As security forces swept through the prison, they found the bodies of two Taliban prisoners apparently killed by the Islamic State group, showing the tensions between the two militant factions battling each other in eastern Afghanistan.
The 29 dead included civilians, prisoners, guards and Afghan security forces, said Attaullah Khogyani, the provincial governor’s spokesman.
The attack began on Sunday, when an Islamic State suicide bomber drove a car laden with explosives up to the prison’s main gate, detonating the bomb.
Islamic State militants opened fire on the prison’s guards and poured through the breach.
The Islamic State group’s affiliate in Afghanistan, known as IS in Khorasan province, later claimed responsibility for the attack. The affiliate is headquartered in Nangarhar province.
The motive of the attack was not immediately clear. However, some of the 1,500 prisoners there escaped during the fighting.
Mr Khogyani said about 1,000 prisoners who earlier escaped had been found by security forces across the city. It was not immediately clear if any prisoners were still at large.
Several hundred prisoners in Jalalabad are believed to be Islamic State members.
The attack came a day after authorities said Afghan special forces killed a senior Islamic State commander near Jalalabad.
While the Islamic State group has seen its so-called caliphate stretching across Iraq and Syria eliminated after a years-long campaign, the group has continued fighting in Afghanistan.
The extremists also have battled the Taliban in the country, whom the US overthrew following the 2001 American-led invasion after the September 11 attacks.
The Taliban’s political spokesman, Suhail Shaheen, told The Associated Press that his group was not involved in the Jalalabad attack.
The US struck a peace deal with the Taliban in February. A second, crucial round of negotiations between the Taliban and the political leadership in Kabul has yet to start.
The Taliban declared a three-day cease-fire starting on Friday for the major Muslim holiday of Eid al-Adha.
The cease-fire expired at 12am on Monday though it was not immediately clear if it would be extended as the US pushes for an early start to intra-Afghan negotiations that have repeatedly been delayed since Washington signed the peace deal with the Taliban.
“We have a cease-fire and are not involved in any of these attacks anywhere in the country,” Mr Shaheen said.
The Taliban also had denied being involved in a suicide bombing in eastern Logar province late on Thursday that killed at least nine people and wounded 40.
Afghanistan has seen a recent spike in violence, with most attacks claimed by the local Islamic State group affiliate.