CAIRO (AP) — In the deadliest-ever attack by Islamic extremists in Egypt, militants assaulted a crowded mosque Friday during prayers, blasting helpless worshipers with gunfire and rocket-propelled grenades and blocking their escape routes. At least 235 people were killed before the assailants got away.

The attack in the troubled northern part of the Sinai Peninsula targeted a mosque frequented by Sufis, members of a mystic movement within Islam. Islamic militants, including the local affiliate of the Islamic State group, consider Sufis heretics because of their less literal interpretations of the faith.

The startling bloodshed in the town of Bir al-Abd also wounded at least 109, according to the state news agency. It offered the latest sign that, despite more than three years of fighting in Sinai, the Egyptian government has failed to deter an IS-led insurgency.

President Abdel-Fattah el-Sissi vowed that the attack “will not go unpunished” and that Egypt would persevere with its war on terrorism. But he did not specify what new steps might be taken.

The military and security forces have already been waging a tough campaign against militants in the towns, villages and desert mountains of Sinai, and Egypt has been in a state of emergency for months. Across the country, thousands have been arrested in a crackdown on suspected Islamists as well as against other dissenters and critics, raising concern about human rights violations.

Seeking to spread the violence, militants over the past year have carried out deadly bombings on churches in the capital of Cairo and other cities, killing dozens of Christians. The IS affiliate is also believed to be behind the 2016 downing of a Russian passenger jet that killed 226 people.

Friday’s assault was the first major militant attack on a Muslim congregation, and it eclipsed past attacks, even dating back to a previous Islamic militant insurgency in the 1990s.

The militants descended on the al-Rouda mosque in four off-road vehicles as hundreds worshipped inside. At least a dozen attackers charged in, opening fire randomly, the main cleric at the mosque, Sheikh Mohamed Abdel Fatah Zowraiq told The Associated Press by phone from a Nile Delta town where he was recuperating from bruises and scratches suffered in the attack.