Militants attacked a crowded mosque with explosives and gunfire during Friday 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 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.

Loading article content

READ MORE: Theresa May condemns "sickening" Egypt mosque attack which left 235 dead

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, and it eclipsed any past attacks of its kind, even dating back to a previous Islamic militant insurgency in the 1990s.

The militants opened fire from four off-road vehicles on the hundreds of worshippers attending the sermon in the mosque.

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.

READ MORE: Theresa May condemns "sickening" Egypt mosque attack which left 235 dead

Dozens of bloodied bodies wrapped up in sheets were laid across the mosque floor, according to images circulating on social media. Relatives queuing up outside the hospital as ambulances raced back and forth.

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 by telephone.

No one immediately claimed responsibility for the attack. But IS has targeted Sufis several times in the area in the past, notably beheading a leading Sufi religious figure, the blind sheikh Suleiman Abu Heraz, last year and posting photos of the killing online.

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

In a statement afterwards, Mr el-Sissi 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. Addressing the nation later on television, he repeated his view that Egypt fighting a battle against militancy on behalf of the rest of the world.

READ MORE: Theresa May condemns "sickening" Egypt mosque attack which left 235 dead

Cairo's international airport boosted security following the attack, with more forces patrolling passenger halls, conducting searches and manning checkpoints at airport approaches.

State condolences poured in for Egypt, including messages from Israel, the United Arab Emirates, the US, Russia, France and Britain condemning the violence.

US President Donald Trump denounced what he called a "horrible and cowardly terrorist attack on innocent and defenceless worshippers in Egypt."

"The world cannot tolerate terrorism" he said on Twitter, "we must defeat them militarily and discredit the extremist ideology that forms the basis of their existence!"

Islamic militants stepped up their campaign of violence in northern Sinai after the military ousted the Muslim Brotherhood from power in 2013.

The result has been a long, grinding conflict centred on el-Arish and nearby villages and desert mountains. The militants have been unable to control territory, but the military and security forces have also been unable to bring security, as the extremists continuously carry out attacks.

Largely the attacks have focused on military and police, killing hundreds, although exact numbers are unclear as journalists and independent investigators are banned from the area. But the militants have also assassinated individuals the group considers spies for the government or religious heretics.

READ MORE: Theresa May condemns "sickening" Egypt mosque attack which left 235 dead

Egypt has also faced attacks by militants in its Western Desert, including an attack last month that killed 16 police, according to an official tally issued by the Interior Ministry.

Security officials have told journalists that dozens more, including high-ranking counter-terrorism officers, perished in the October 20 attack some 84 miles south-west of the capital, Cairo.