At least 29 people have been killed in an attack on a prison in the eastern Afghan city of Jalalabad which saw more than 1,000 inmates try to flee.
The attack, claimed by the Islamic State group (IS), began on Sunday evening when car bombs were detonated at the prison's entrance by gunmen.
Eight of the attackers were killed in a battle lasting almost 20 hours, a Nangarhar province spokesman said.
As many as 300 inmates are believed to be still on the run.
There were 1,793 prisoners in the jail at the time of the attack - most of them Taliban and IS fighters, a security source told the AFP news agency. It was not immediately clear if the attack had been staged to free specific prisoners.
Those accused of general crimes were also held in the prison.
According to the provincial spokesman, 1,025 escaped prisoners have been brought back to the jail, and 430 have been rescued. More than 50 people were injured.
IS trying to stage a comeback
Analysis by Dawood Azami, BBC World Service
Jailbreaks are a known tactic for combatants in Afghanistan.
But the well co-ordinated group attack on a prison complex in Jalalabad is one of the biggest and most complex assaults claimed by IS in the country.
Eastern Afghanistan has been the main stronghold of IS since it announced the establishment of its Khorasan Province (ISKP) - an IS branch in the Afghanistan-Pakistan region - in January 2015.
IS had been weakened as a result of several military operations by the Afghan government, the Afghan Taliban and US forces over the past two years.
But the recent deadly attacks claimed by IS show the Afghan government and the Afghan Taliban exaggerated the defeat and even elimination of the group.
Despite recent losses of territory and fighters, IS still has sleeper cells mainly in the cities, especially in Kabul and Jalalabad.
By carrying out such attacks, IS wants to show its resilience and give the impression that its network and capabilities still remain intact.
The attack is also part of an effort by the newly-appointed ISKP leader to prove his credentials, boost the morale of his followers and possibly attract new recruits. In a recently released statement, he reassured the IS captives that their colleagues would not "sit idle".
The attack happened on the third and final day of a temporary ceasefire between the Afghan government and the Taliban, with hundreds of Taliban prisoners released in an effort to get peace talks moving between the two sides.
The Taliban - which is a staunch rival of IS - had earlier said it was not responsible for the attack.
IS was not part of the ceasefire deal.
You might also be interested in...
Sunday's attack came a day after Afghanistan's intelligence agency announced that the country had killed a top IS commander, Assadullah Orakzai, near Jalalabad. Orakzai had allegedly been involved in several deadly attacks against Afghan security forces.
Nangarhar province was the Islamic State group's first stronghold in Afghanistan. It still has a foothold there, despite government officials claiming last year that the group's local affiliate - known as Islamic State Khorasan - had been completely defeated in the province.
Nangarhar had already seen deadly attacks this year, including a 12 May suicide bombing that killed 32 mourners at a funeral for a police commander.