* Graphic - tmsnrt.rs/2yLdIjT (Adds witness comments, other details)
By Omar Fahmy and Patrick Markey
CAIRO, Nov 25 (Reuters) - Gunmen who attacked a mosque on Friday in Egypt’s North Sinai brandished an Islamic State flag as they opened fire through doorways and windows, killing more than 300 worshippers, including two dozen children, officials said on Saturday.
No group has claimed responsibility, but Egyptian forces are battling a stubborn Islamic State affiliate in the region, one of the surviving branches of the militant group after it suffered defeats by U.S.-backed forces in Iraq and Syria.
The assault on a mosque has stunned Egyptians, prompting President Abdel Fattah al-Sisi’s government to tighten security at places of worship and key buildings, and call three days of mourning for the bloodiest attack in Egypt’s modern history.
State news agency MENA said the death toll had risen to 305, including 27 children, and 128 people were injured.
Egypt’s public prosecutor’s office, citing interviews with wounded survivors as part of its investigation, linked Islamic State militants, also known as Daesh, to the attack on the Al Rawdah mosque in Bir al-Abed, west of El-Arish city.
“The worshippers were taken by surprise by these elements,” the prosecutor said in a statement. “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.”
The gunmen, some wearing masks and military-style uniforms, had arrived in jeeps, surrounded the mosque and opened fire inside, sending panicked worshippers scrambling over each other to escape the carnage.
Witnesses had said gunmen set off a bomb at the end of Friday prayers and then opened fire as people tried to flee, shooting at ambulances and setting fire to cars to block roads. Images on state media showed bloodied victims and bodies covered in blankets inside the mosque.
“When the shooting began everyone was running, and everyone was bumping into one another,” Magdy Rezk, a wounded survivor, said from his hospital bed. “But I was able to make out masked men wearing military clothing.”
Striking a mosque would be a shift in tactics for the Sinai militants, who have previously attacked troops and police and more recently tried to spread their insurgency to the mainland by hitting Christian churches and pilgrims.
Local sources said some of the worshippers were Sufis, whom groups such as Islamic State consider targets because they revere saints and shrines, which for Islamists is tantamount to idolatry. Islamic State has targeted Sufi and Shi‘ite Muslims in other countries like Iraq.
The jihadists in Egypt’s Sinai have also attacked local tribes and their militias for working with the army and police.
Sisi, a former armed forces commander who supporters see as a bulwark against Islamist militants, promised the “utmost force” against those responsible for Friday’s attack. Security has been a key reason for his supporters to back him, and he is expected to run for re-election next year.
Egypt’s military carried out air strikes and raids overnight to target hideouts and vehicles involved in the attack, the army said, without giving details on the number of militants.
“What is happening is an attempt to stop us from our efforts in the fight against terrorism,” Sisi said on Friday.
The Sinai attack came as Sisi’s government looks to draw more foreign investment and finish an IMF reform programme to help revive an economy that struggled through instability after the 2011 uprising ousted long-standing leader Hosni Mubarak.
North Sinai, a mostly desert area stretching from the Suez Canal eastwards to the Gaza Strip and Israel, has long been a security headache for Egypt and is a strategic region for Cairo because of its sensitive borders.
Local militant group Ansar Bayt al-Maqdis, once allied to al Qaeda, split from it and declared allegiance to Islamic State in 2014. But attacks in the Sinai worsened after 2013 when Sisi led the overthrow of President Mohamed Mursi of the Muslim Brotherhood after mass protests against his rule.
Writing by Patrick Markey; editing by Alexander Smith and Jeremy Gaunt