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.
MORE: Video shows chaotic scene after Egypt mosque attack
The startling bloodshed in the town of Bir al-Abd also wounded at least 109, according to the state news agency, and 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.
MORE: Egypt mosque attack witness says "The sight was horrific, I can't describe it'
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.
He said there were explosions as well. Officials cited by the state news agency MENA said the attackers fired rocket-propelled grenades and shot men as they tried to run from the building. The militants blocked off escape routes with burning cars, three police officers on the scene told The Associated Press, speaking on condition of anonymity because they were not authorized to talk to the press.
Abdullah Abdel-Nasser, 14, who was attending prayers with his father, said the shooting began just as the cleric was about to start his sermon, sending panicked worshippers rushing to hide behind concrete columns or whatever shelter they could find. At one point, a militant shouted for children to leave, so Abdel-Nasser said he rushed out, though he was wounded in the shoulder by shrapnel and a bullet.
"I saw many people on the floor, many dead. I don't think anyone survived," he said at a hospital in the Suez Canal city of Ismailia, where around 40 of the wounded were taken, including many children.
Mohammed Ali said 18 members of his extended family were killed in the attack. The mosque belonged to a local clan, the Jreer, so many of its members worshipped there.
"Where was the army? It's only a few kilometers away. This is the question we cannot find an answer to," he said.
The attackers escaped, apparently before security forces could confront them.
Afterward, dozens of bloodied bodies wrapped in sheets were laid across the mosque floor, according to images circulating on social media. Relatives lined up outside a nearby hospital as ambulances raced back and forth. The state news agency MENA put the death toll at 235.
Resident Ashraf el-Hefny said many of the victims were workers at a nearby salt mine 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 claimed immediate responsibility for the attack. But the IS group affiliate has targeted Sufis in the past. Last year, the militants beheaded a leading local Sufi religious figure, the blind sheikh Suleiman Abu Heraz, and posted photos of the killing online.
Islamic State group propaganda often denounces Sufis. In the January edition of an IS online magazine, a figure purporting to be a high level official in the Sinai affiliate of the group vowed to target Sufis, accusing them of idolatry and heretical "innovation" in religion and warning that the group will "not permit (their) presence" in Sinai or Egypt.
Millions of Egyptians belong to Sufi orders, which hold sessions of chanting and poetry meant to draw the faithful closer to God. Sufis also hold shrines containing the tombs of holy men in particular reverence.
Islamic hardliners view such practices as improper, even heretical, and militants across the region often destroy Sufi shrines, saying they encourage idolatry because people pray to the figures buried there for intercession.
El-Sissi convened a high-level meeting of security officials as his office declared a three-day mourning period.
In a statement, he said the attack would only "add to our insistence" on combatting extremists. Addressing the nation later on television, he said Egypt is waging a battle against militancy on behalf of the rest of the world, a declaration he has often made in seeking international support for the fight.
President Donald Trump denounced what he called a "horrible and cowardly terrorist attack on innocent and defenseless worshippers."
"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!" He later tweeted that he would call el-Sissi and said the attack showed the need to get "tougher and smarter," including by building the wall he has promised along the U.S. border with Mexico.
Islamic militants stepped up their campaign of violence in northern Sinai after the military ousted the elected but divisive Islamist Mohammed Morsi from power in 2013 and launched a fierce crackdown on Morsi's Muslim Brotherhood group.
The result has been a long, grinding conflict centered on el-Arish and nearby villages. 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.
The attacks have largely focused on military and police, killing hundreds, although exact numbers are unclear as journalists and independent investigators are banned from the area. The militants have also assassinated individuals the group considers spies for the government or religious heretics.
Egypt has also faced attacks by militants in its Western Desert.