Militants attacked a crowded mosque with explosives and gunfire during prayers in the Sinai Peninsula, killing more than 230 people in the deadliest attack by Islamic extremists in Egypt.

The attack targeted a mosque frequented by Sufis, members of Islam’s mystical movement, in the north Sinai town of Bir al-Abd.

Islamic militants, including the local affiliate of the Islamic State (IS) group, consider Sufis heretics because of their less literal interpretations of the faith.

The startling bloodshed, which also wounded at least 109, was the latest sign of how more than three years of fighting in Sinai has been unable to crush an insurgency waged by the IS affiliate.

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

But this was the first major militant attack on a Muslim mosque.

The militants opened fire from four off-road vehicles on the hundreds of worshippers attending the sermon. They also blocked off escape routes from the area by blowing up cars and leaving the burning wrecks blocking the roads, three police officers on the scene said.

Dozens of bloodied bodies wrapped up in sheets were laid across the mosque floor, according to images circulating on social media.

Resident Ashraf el-Hefny said many of the victims were workers at a nearby salt factory who had come for Friday services at the mosque.

“Local people brought the wounded to hospital on their own cars and trucks,” he said.

No-one immediately claimed responsibility for the attac, but IS has targeted Sufis several times in the area in the past.

Egypt’s presidency declared a three-day mourning period, as President Abdel-Fattah el-Sissi convened a high-level meeting of security officials.

He said the attack “will not go unpunished” and that Egypt will persevere with its war on terrorism.

The suffering of the victims was not in vain, he added, and will only “add to our insistence” to combat extremists.

Prime Minister Theresa May described the attack as “sickening”.