NO SOONER had Egypt’s army booted out Muhammad Morsi from the presidency in Cairo than armed Islamists took over the governor’s offices in el-Arish, the provincial capital at the northern end of the Sinai peninsula. Armed Islamist guards protected gatherings of fellow militants in the town’s main square who waved the black flags of Tawhid wal Jihad, which claims to be an al-Qaeda affiliate. One of the speakers was a man accused of bombing a tourist hotel in 2004 in Taba, at the south-eastern end of Sinai, close to Israel. “We’re another Afghanistan,” moans the mayor, Amar Goda.

To the south-east of el-Arish the town of el-Gorah, near the base of the multinational forces and observers (MFO) that are supposed to monitor the treaty between Israel and Egypt, soon looked like a war zone. On July 5th a score of masked men in black uniforms, wielding heavy weapons, shot their way into the town centre, killing two soldiers standing by their tanks. Egyptian soldiers shifted to the rooftops, training their guns on the market below. The army tried to enforce a night-time curfew. The MFO’s monitors, drawn from a dozen countries, including Australia, Colombia, Fiji and the United States, hunkered down nervously in their base.

Most of the gunmen are Bedouin who have long-standing grievances against the central government in Cairo. They say they are barred from joining the army or police; they find it hard to get jobs in tourism; and they complain that many of their lands have been taken from them. Exploiting the situation, militant Islamists have jumped on the Bedouin bandwagon.

Islamist fighters from Gaza allied to Mr Morsi’s Muslim Brotherhood are said to have formed a vanguard in Sinai in the hope of deterring the Egyptian army from blockading the Palestinian enclave from the west, as it did under President Hosni Mubarak before he was ousted two years ago. It may now offer a haven in Sinai to defiant Muslim Brothers in the wake of Mr Morsi’s downfall. “Those who sprayed Morsi with water will be sprayed with blood,” says a Brotherhood leader. Jihadist groups, spotting the vacuum, have been roaming the ungoverned wastelands of Sinai for some time. A leading Algerian jihadist has declared that Sinai will not be peaceful until Mr Morsi returns to office. As turmoil grips much of the rest of Egypt, an array of malcontents is converging on the peninsula.

Only if Egypt can be quickly put back on the path to democracy can Sinai be prevented from turning into a battlefield of Islamists pitted against the Egyptian army, says Mr Goda. The generals have already, since Mr Morsi’s removal, deployed helicopters and tanks in what was once a demilitarised zone.

Both the Bedouin and members of the Brotherhood fear that the generals may send back the state security forces, who tortured thousands of people in a counter-insurgency campaign against terrorists after tourist hotels in Sharm el-Sheikh were bombed in 2005. During the Egyptian revolution in 2011 the security servicemen were sent packing by the locals.

Armed Islamists have also resumed their old trick of bombing the gas pipeline through Sinai which used to supply Israel and Jordan. And since Mr Morsi’s departure, rockets have been fired at Israel’s tourist resort, Eilat. Egyptian soldiers have also been shot; one was in a hospital bed in el-Arish.

Scores of security people are said to have been killed in Sinai since Mr Mubarak’s fall in 2011. “The Salafist armed groups were putting their trust in the ballot box,” says Mr Goda. “Now that they see our democracy is a sham, they will trust in bullets again—and drag the Brothers in, too.”