KABUL — The Islamic State claimed responsibility for storming a major prison in eastern Afghanistan on Sunday in a surprise attack that freed prisoners.

The raid began with a car bomb at one of the prison’s gates, allowing gunmen to move into the complex in central Jalalabad. Afghan special forces were dispatched to the scene, where they battled the militants for hours. Early Monday, the raid was still continuing, and local media outlets reported that hundreds of inmates had escaped.

Shortly after the raid began, the Taliban tweeted a brief statement denying responsibility.

The attack occurred just hours before a three-day cease-fire between the Taliban and Afghan government forces was set to expire. The truce was intended as a confidence-building measure to aid in the push for direct peace talks. Negotiations have been delayed for months following the signing of the U.S.-Taliban peace deal by an uptick in violence and a controversial prisoner swap.

Several prisoners escaped the complex, but “a number” of them were quickly taken back into custody by police, Nangahar government spokesman Attaullah Khogyani said. He declined to disclose specific numbers.

At least three people were killed and 24 wounded in the initial car bomb attack, the Associated Press reported. Afghan officials did not release information on casualties among security forces or prisoners.

Although the Taliban denied involvement, the complex nature of the attack mirrored past Taliban assaults on other prisons in Afghanistan. A Taliban raid on a prison in Ghazni in 2015 freed more than 350 prisoners. That attack, too, began with a car bomb that breached the complex’s perimeter before gunmen stormed the buildings.

Afghan security officials said the attack could have been carried out by a Taliban splinter group to upset the push for direct peace talks. The concern touches on questions surrounding unity within the Taliban movement and the ability of Taliban political leadership in Qatar to control the group’s fighters on the ground. Both issues are becoming increasingly important in the lead-up to peace talks.

The officials spoke on the condition of anonymity because they were not authorized to brief the media.

The Islamic State has stepped up recruiting from within the most extreme ranks of Taliban fighters. Afghanistan’s Islamic State offshoot has claimed responsibility for several recent attacks in Kabul in which gunmen stormed buildings and held off security forces for hours, but none as complex as Sunday’s prison raid.

Jalalabad’s central prison holds Islamic State-linked fighters as well as those linked to the Taliban, but the most senior fighters from both groups are held in prisons in Kabul.

Until the attack Sunday, the cease-fire announced by the Taliban to mark the Muslim holiday of Eid had largely quelled violence across Afghanistan. A handful of low-level security incidents were reported nationwide but the cease-fire was largely respected.

The Islamic State was not a party to the cease-fire, and Sunday’s attack would probably not constitute a violation of the truce. But the prison raid did highlight the kind of violence that could continue in Afghanistan despite a peace deal with the Taliban.

Before Eid, the Afghan government announced it would release 5,000 prisoners as the Taliban demanded before talks could begin. But the sides remain at odds over who should be included in the 5,000. Taliban officials are asking for 100 fighters linked to deadly high-profile attacks to be released, a move strongly opposed by government officials and international human rights organizations.