A gunbattle between Islamic State fighters and Afghan security forces raged at a prison in the eastern city of Jalalabad on Monday, with at least 24 people killed after the militants' overnight assault led to a mass jailbreak.
The attack began on Sunday evening with car bomb detonated at the entrance to the prison, and there were numerous other blasts heard as the IS gunmen opened fire on security guards.
Some 30 militants involved in the attack on the prison, where some 2,000 prisoners were held, according to Sohrab Qaderi, a lawmaker in the capital of Nangarhar province.
Three militants were killed during the initial attack and gunbattle overnight, while at least 21 civilians and members of security forces died in the fighting, and 43 were wounded, Attaullah Khugyani, a spokesman for the governor said.
Police were forced to divert manpower to recapture escaped prisoners amid the chaos, and by noon on Monday around 1,000 had been caught, Qaderi said, without elaborating on how many were still at large.
Afghan special forces arrived to support police, according to officials, and civilians were being evacuated from areas surrounding the prison, where Taliban and IS prisoners were being held along with ordinary criminals.
Meanwhile the city was in lockdown.
"The whole city of Jalalabad is under curfew, shops are closed," Qaderi said. "Jalalabad is completely empty."
IS claimed responsibility for the attack, which came a day after the Afghan intelligence agency said special forces had killed a senior commander of the group near Jalalabad, the provincial capital of Nangarhar.
Some 130 kilometres (80 miles) east of Kabul, Jalalabad lies on the highway leading to the Khyber Pass and the Pakistani city of Peshawar.
A United Nations report last month estimated there are around 2,200 IS members in Afghanistan, and that while the group is in territorial retreat and its leadership has been depleted, it remains capable of carrying out high-profile attacks.