CAIRO — Islamist militants detonated explosives and sprayed gunfire at a crowded Sufi mosque near Egypt’s Sinai coast on Friday, killing at least 235 people and wounding 109 more, in one of the deadliest attacks on civilians in the country’s modern history.
Attacks on mosques are rare in Egypt, where the Islamic State has targeted Coptic Christian churches and security officials in recent years. So the devastating attack on the mosque in Beer al-Abd, 125 miles northeast of Cairo, sent shock waves across the country.
“I can’t believe they attacked a mosque,” a Muslim cleric in the town said by phone. He requested anonymity for fear he could also be attacked.
Even by recent standards in Egypt, where militants have blown up Christian worshipers in church pews and gunned down pilgrims in buses, it was an unusually ruthless and deadly assault.
The attackers, who traveled in four-wheel-drive vehicles, exploded bombs inside the mosque, then sprayed worshipers with gunfire as they fled, state media reported. A military official said that a suicide bomber was involved in the attack.
The gunmen lingered at the scene even as emergency workers arrived to treat the injured, and opened fire on several ambulances, Ahmed el-Ansari, a senior government health official, said on state television.
Many of the wounded were rushed to the general hospital in the main town in Sinai, El Arish, where medics described chaotic scenes as staff struggled to deal with a flood of dead of injured.
“They pretty much have bullets in every part of their bodies,” said one medical official, speaking by phone, referring to gunshot victims. Others had extensive burns or lost limbs due to the explosion.
“We are swamped. We don’t know what to say. This is insane,” he said, asking not to be named out of fear he could be victimized by either the militants or the security forces.
The worshipers at the mosque were Sufi Muslims, who practice a mystical form of Islam that some orthodox Muslims and Sunni extremists consider heretical. The Islamic State had threatened and killed a number of Sufis in Bir al-Abd in recent months, but the group never targeted a place of worship, the cleric said.
President Abdel Fattah el-Sisi convened an emergency meeting of top security officials including the interior minister, spy chief and defense minister. He declared three days of mourning. Nabil Sadek, Egypt’s top prosecutor, ordered an investigation into the attack.
The Egyptian military, which has been battling a local affiliate of Islamic State in northern Sinai for years, declared a curfew in Bir al-Abed and El Arish. Violence in Sinai surged after 2013, when Mr. Sisi came to power in a military takeover that deposed the democratically elected president Mohamed Morsi of the Muslim Brotherhood.
In Sinai the Egyptian military was pitted against an Islamist militia called Ansar Beit al-Maqdis that in 2014 pledged allegiance to Islamic State, and which has since proven to be one of the group’s most effective local affiliates. The group’s most successful attack targeted a Russian jetliner that crashed shortly after takeoff from Sharm el Sheikh in October 2015, killing all 224 people on board.
In addition, Egyptian security forces have been closely monitoring returning Islamic State fighters from Syria and Iraq, amid worries that an influx of battle-hardened jihadis could inject a volatile new element into Egypt’s militant mix.
The bombing comes as the Egyptian authorities have been hoping to stem the tide of Islamist violence in Sinai, thanks to their sponsorship of a Palestinian peace initiative involving Hamas, the militant group that controls Gaza.
Islamic State militants have previously used tunnels into Gaza to source weapons and get medical treatment for wounded fighters. One benefit for Egypt of the peace initiative, which Egypt’s General Intelligence Directorate has mediated, is greater control over those tunnels.
The Egyptian security forces have been closely monitoring returning Islamic State fighters from Syria and Iraq, amid worries that an influx of battle-hardened jihadis could inject a volatile new element into Egypt’s militant mix.
Many residents in Bir al-Abed, which is on the main road through northern Sinai, are Bedouins from a tribe called the Abu Greir, who are predominantly Sufi. Residents said that, despite the recent threats by Islamic State, the town had been considered largely peaceful. The peace deal involving Hamas had further raised hopes that security was improving.
In a statement, Hamas issued denounced the attack as a “criminal explosion” that “violates all heavenly commandments and human values” because it attacked a mosque. “It is a grave challenge to Muslims worldwide,” the group said.
Over the past year, Islamic State militants have carried out a series of attacks on Christians in Egypt that have killed more than 100 people. In October, Mr. Sisi ordered a major reshuffle of his security team after an ambush in the desert left at least 16 Egyptian security officials dead.
That attack was later claimed by a previously unknown group called Ansar al-Islam, which is believed to have links to Al Qaeda.