CAIRO — In the deadliest attack on civilians in Egypt’s modern history, Islamist militants detonated a bomb inside a crowded mosque on Friday and then sprayed gunfire on panicked worshipers as they fled the building, killing at least 235 people and wounding at least 109 others.
The scale and ruthlessness of the assault, which occurred in a small town in the insurgency-racked Sinai Peninsula, sent shock waves across the nation, not just for the number of deaths but also for the choice of target. Attacks on mosques are rare in Egypt, where the Islamic State has targeted Coptic Christian churches and pilgrims but avoided Muslim places of worship.
The attack injected a new element into Egypt’s volatile stew because most of the victims were Sufi Muslims, who practice a mystical form of Islam that some extremists deem heretical. And it underscored the failure of President Abdel Fattah el-Sisi, who has insisted he needs to crush political opposition to combat the threat of Islamist militancy, to deliver on his promises of security to ordinary Egyptians.
“We will respond to the terrorist attack in Al Rawda,” Mr. Sisi vowed in a televised speech. “The military and the police will take revenge.”
He convened an emergency meeting of top security officials including the interior minister, spy chief and defense minister. Egyptian military aircraft later carried out several airstrikes, targeting militants fleeing the area in four-wheel-drive vehicles, an Egyptian military official said.
The Egyptian military, which has been battling a local affiliate of Islamic State in northern Sinai for years, declared a curfew in the town of Bir al-Abed, where the attack took place, and in the main northern Sinai town of 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.
Even by recent standards in Egypt, where militants have blown up Christian worshipers as they knelt at church pews and gunned down pilgrims in buses, it was an unusually ruthless assault.
“I can’t believe they attacked a mosque,” a Muslim cleric in Bir al-Abed said by phone, requesting anonymity for fear he could also be attacked. In recent months, the Islamic State had threatened and killed a number of Sufis there but it had not attacked a place of worship, the cleric said.
The attack started midday during Friday Prayers when a bomb — mostly likely set off by a suicide bomber, according to security officials — ripped through Al Rawda mosque in Bir al-Abed, a small town 125 miles northeast of Cairo. As worshipers fled, they were confronted with group of gunmen who, witnesses said, had pulled up outside in a four-wheel-drive vehicles.
Some of the gunmen rushed into the mosque, where they opened fire on the worshipers. Others waited outside, picking off those who had managed to flee.
The gunmen lingered at the scene even as emergency workers arrived to treat the wounded, opening fire on several ambulances, Ahmed el-Ansari, a senior government health official, said on state television.
Mayna Nasser, 40, who was shot twice in the shoulder, drifted in and out of consciousness as he was rushed to hospital. “My children were there, my children were there,” he said, according to Samy, the volunteer emergency medical worker who drove him there and who declined to give his last name.
Samy, who spoke by phone, said the emergency services in Bir al-Abed were so overwhelmed that some of the wounded had to be transported to the hospital in the back of cattle truck.
Many were taken to the general hospital in the El Arish, where medics described chaotic scenes as staff struggled to deal with a flood of dead and wounded. “They pretty much have bullets in every part of their bodies,” said one medical official, speaking by phone. Others had extensive burns or limbs lost from the explosion.
“We are swamped,” he said, speaking on condition of anonymity. “We don’t know what to say. This is insane.”
“The world cannot tolerate terrorism, we must defeat them militarily and discredit the extremist ideology that forms the basis of their existence!” he said.
In Sinai, the Egyptian military has been battling an Islamist militia called Ansar Beit al-Maqdis, which pledged allegiance to the Islamic State in 2014 and has since proved to be one of the group’s most effective local affiliates. The group’s deadliest attack targeted a Russian jetliner that crashed shortly after takeoff from Sharm el Sheikh in October 2015, killing all 224 people on board.
Egyptian security forces have also been closely monitoring returning Islamic State fighters from Syria and Iraq, amid worries that an influx of battle-hardened jihadis could insert a volatile new element into Egypt’s militant mix.
The Egyptian authorities have been hoping to stem the tide of Islamist violence in Sinai through their sponsorship of a Palestinian peace initiativeinvolving 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.
Until the spate of attacks on Christian churches this year, Egyptian militants had avoided large-scale assaults on Egyptian civilians, perhaps because history taught that they tended to backfire. After a massacre in Luxor that killed 62 people, mostly tourists, in 1997, President Hosni Mubarak launched a sweeping crackdown that crushed the Islamist insurgency centered in southern Egypt.
When a new insurgency flared in the north Sinai after the military takeover in 2013, the extremists leading it were careful to focus their attacks on the uniformed security forces they blamed for the military takeover. But as those militants embraced the Islamic State, also known as ISIS or ISIL, they have gradually set aside that lesson.
Many residents of Bir al-Abed, on the main road through northern Sinai, are Bedouins from the Abu Greir tribe, which is predominantly Sufi. Residents said that despite the recent threats by Islamic State the town had been largely peaceful. The peace deal involving Hamas had further raised hopes that security was improving.
But the Islamic State, a radical Sunni movement, has long considered Sufis apostates, along with Shiite Muslims, and has a history of attacking their mosques in other countries. Sufis can be Sunni or Shiite but most are Sunni.
The Islamic State in particular rejects the Sufi practice of praying at the tombs of saints, which it views as a form of idolatry. Since 2016, when the group released a video describing Sufism as a “disease,” it has claimed attacks that have killed at least 130 worshipers at Sufi shrines, most of them in Pakistan.
Elsewhere, ISIS has made a spectacle of bulldozing Sufi shrines, describing their removal as a form of purifying the faith.
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.
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.