Two years to the day after the army overthrew Egypt's Islamist president, the sounds coming from the mosque at Cairo's Tahrir Square were sadly telling. At the focal point of Egypt's upheavals, where authorities had hoped to stage celebrations, there was instead a prayer for the week's dead, including soldiers cut down by militants in Sinai and the country's chief prosecutor, assassinated by car bomb in the capital.

A sense of foreboding fills the air, with officials and media speaking of a state of war and urging national unity. President Abdel-Fattah el-Sissi has promised swift justice, which critics fear will mean a further step away from democracy. The Muslim Brotherhood, banned but unbowed, has upped the ante by calling for revolt against his rule. There is fear of even worse attacks of the kind that have become sadly familiar around the region.

It all presents a major challenge for el-Sissi, who as army chief led the takeover against Morsi two years ago, when millions filled the streets outraged over Muslim Brotherhood misrule. He was later elected president, and the deal he has offered Egyptians — a curtailing of freedoms in exchange for stability and security — was one many seemed eagerly willing to embrace after several years of upheaval, in which the wider region has gone up in flames.

The first part of that equation has been carried out: the once-ruling Muslim Brotherhood has been largely crushed, thousands of its top people in jail and hundreds — including Morsi — handed the death penalty; public protests are restricted, as is political activity; the media has been cowed amid an atmosphere that seems to equate criticism with disloyalty; and even many liberal activists are in jail. The result has been quieter streets, without protests that often turned to riots the past three years, and violence against Christians and Shiites has lessened, though not stopped.

But stability, which for a time seemed attainable, seems to be in danger of unraveling. Militants affiliated with the regional Islamic State group have turned the northern part of the Sinai peninsula into a war zone, this week staging a brazen multi-pronged attack on army positions; last month a key tourist site at Luxor was attacked; on Tuesday chief prosecutor Hisham Barakat was assassinated while leaving his Cairo home for work.

Islamic radicals have claimed responsibility for the attacks. Authorities generally blame the Muslim Brotherhood itself, claiming its leaders issue orders from behind bars. Some believe the group's denials while others don't, and proof is scarce.

Michael Hanna, a senior fellow at the U.S.-based Century Foundation, sees an "escalatory cycle ... deteriorating security is eroding confidence in capacity of the regime but at the same time also reinforcing hard-line trends in Egyptian society with respect of how to deal with these security threats."

After the killing of Barakat, an angry el-Sissi went on TV to promise more efficient justice. He also suggested that the death penalties against the Islamist leaders would — contrary to expectations — actually be carried out.

Action will be taken within days "to enable us to execute the law, and bring justice as soon as possible," he said. In a thinly veiled reference to jailed members of the Brotherhood, el-Sissi blamed the violence on those "issuing orders from behind bars," and warned: "If there is a death sentence, it will be carried out."

"We will stand in the face of the whole world, and fight the whole world," el-Sissi said.

El-Sissi was alluding to the widespread global criticism of his heavy-handed rule — charges certainly also echoed by domestic opponents, not all of them Islamists.

On Friday, hundreds of mostly young Islamist demonstrators held several small protests in Cairo suburbs on Friday, carrying pro-Morsi signs and chanting "down with military rule."

But el-Sissi also has wide support among Egyptians who have come to feel that liberal democracy is a bad fit in a society where almost half the people are illiterate and significant political forces would, if allowed, create a theocracy which would hardly be democratic.

"There's progress and stability, we feel more order in the streets and the economy. But there's nobody who's not sad in Egypt these days because of the attacks in Sinai," said Ibrahim Hamdy, a shopkeeper at a hardware store in a popular neighborhood of central Cairo, where Ramadan decorations hung from the buildings.

The crackdown on the Brotherhood and other opponents following Morsi's ouster claimed hundreds of lives and landed thousands in jail. With most of the Brotherhood cadres in jail, youth supporters have been left leaderless. Some still protest several times a week in dilapidated Cairo suburbs where alleyways are too narrow for tanks to enter, or restive rural areas off-limits to the state.

Unprecedented, coordinated attacks by militants including massive suicide bombings on the army in the Sinai Peninsula on Wednesday underlined the failure to stem an insurgency that blossomed in the area after Morsi's overthrow, despite a heavy-handed crackdown.

The army said 17 soldiers and over 100 militants were killed, although before the release of its official statement, several senior security officials from multiple branches of Egypt's forces in Sinai had said that scores more troops also died in the fighting. The same day, a special forces raid on a Cairo apartment killed nine leaders of the outlawed Brotherhood, which said they were innocents "murdered in cold blood," and called for a "rebellion."

Sinai's main insurgent organization, which calls itself the Sinai Province of the Islamic State group, claimed responsibility for Wednesday's assault. El-Sissi has yet to address the public about the attacks, but in the past he has described the Brotherhood the root of all Islamic extremist groups. Just two days earlier, the assassination of Barakat was claimed by an obscure militant group.

The week's events have pushed aside, for now, the talk of Egypt's budding economic recovery. GDP is accelerating, foreign investment has doubled in a year and the stock market is rising. Unemployment is down and the country's credit ratings are up. Gas lines are gone and the country has capital to invest, thanks in part to a multi-billion dollar aid package from Saudi Arabia and the United Arab Emirates.

Among Brotherhood's supporters, calls to abandon non-violence are growing, deepening an internal split over the issue. On Wednesday the group issued a call for revolt which may reinforce those urging the use of force.

Cairo-based security expert H.A. Hellyer said it was not inevitable but "increasingly likely" that the call will result in "a more militant and insurgency-style route." Hellyer, of London's Royal United Services Institute, said such calls would find "a much more receptive audience against the backdrop of the political realities in Egypt and the crackdown."

The events do not bode well for attempts to support democracy, form a more pluralistic society, or even elect a parliament, which el-Sissi had said would come at the end of the year.

Those elections, whenever they take place, are likely to produce a strongly pro-el-Sissi legislature. Islamists, in various forms, may still have a solid base of support but are likely to largely boycott — something that allowed el-Sissi to easily win election a year ago. The existing non-Islamic parties, an assortment of nationalists and liberals, were disorganized and hapless in opposition to Morsi and largely back el-Sissi now.

___

Follow Rohan on Twitter at www.twitter.com/Brian_Rohan