The gunmen who attacked a mosque in Egypt's North Sinai during Friday prayers (24 November) were carrying an Isis flag, according to Egypt's state prosecutor.

Between 25 to 30 men opened fire from five SUVs on the al-Rawdah mosque in the town of Bir al-Abd, 40km (25 miles) from the provincial capital of el-Arish. It is the bloodiest attack in Egypt's history.

The masked militants killed more than 300 Sufi Muslims, including two dozen children, state officials said on Saturday (25 November). 128 people were injured in the attack.

The extremists had long hair and beards, were armed with heavy machine guns and were bearing an Isis flag, according to the prosecutor.

It said the attackers positioned themselves at the main door and the facility's 12 windows before opening fire. They also torched seven cars parked outside the mosque, which belonged to worshippers inside.

"The worshippers were taken by surprise by these elements," the statement said. "They numbered between 25 and 30, carrying the Daesh flag and took up positions in front of the mosque door and its 12 windows with automatic rifles."

"When the shooting began everyone was running, and everyone was bumping into one another," Magdy Rezk, a wounded survivor, told Reuters.

Survivors spoke of horrific scenes during the approximately 20 minutes it took the militants to kill and maim worshippers. They spoke of some jumping out of windows, a stampede in a corridor leading to the washrooms and of children screaming in horror. Some spoke of their narrow escape from a certain death, others of families that lost all or most of their male members.

After the attack, President Abdel Fattah al-Sisi declared three days of mourning and said security would be tightened at places of worship and key buildings.

Mansour, a 38-year-old worker in a nearby salt factory, said he settled in Bir al-Abd, the small town near where the attack took place, three years ago to escape the bloodshed and fighting elsewhere in northern Sinai. He suffered two gunshot wounds in the legs on Friday.

"Everyone lay down on the floor and kept their heads down. If you raised your head you get shot," he said. "The shooting was random and hysterical at the beginning and then became more deliberate: Whoever they weren't sure was dead or still breathing was shot dead."

The militants were shouting Allahu Akbar, or God is great, and the children were screaming, Mansour told AP.

"I knew I was injured but I was in a situation that was much scarier than being wounded. I was only seconds away from a certain death," he said. As the shooting took place, many of the worshippers recited their final prayers, he added.

1 of 2

Friday's attack 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.

No one claimed 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.

Egypt launched air strikes targeting militant hideouts following the deadly attack.

Egypt has been fighting an Islamist insurgency since President Mohammed Morsi was ousted in 2013.

Isis-affiliated fighters have in the past targeted followers of the Sufi branch of Sunni Islam as well as Christians. More than 100 members of the Coptic Orthodox community have been killed since December by militants affiliated to Isis.