Fears of weeks of tension as results point to a run-off between the Muslim Brotherhood candidate and a former general

Egypt looks set for weeks of tension and uncertainty after the first round of its landmark presidential election produced a runoff between the candidate backed by the powerful Muslim Brotherhood and a former general who is seen as a hangover from the regime of the deposed Hosni Mubarak.

In what many described as a "nightmare scenario" that will mean a polarised and possibly violent second round, Mohammed Morsi of the Brotherhood's Freedom and Justice Party polled around 26% in the two-day first round. Ahmed Shafiq, Mubarak's last prime minister, came second with 23% when 90% of the votes had been counted.

Amr Moussa, the former head of the Arab League, who tried to capture the centre ground, was knocked out. Late on Friday there was only a slight chance that the final picture would change when votes for Cairo and Giza were in.

Turnout was said to be around 40% of the 51m-strong electorate. Official results are yet to be published but a combination of exit polls, centrally collected data and reporting by the candidates appeared to confirm a dramatic runoff that many supporters of the revolution consider a catastrophic outcome. "It feels as if the revolution never took place," lamented a despondent George Ishaq, a founder of the leftwing Kifaya Party.

"The Brotherhood are despotic and fanatical and Shafiq is the choice of Mubarak. It is a very bad result. The revolution is not part of this contest."

Analysts predict a bare-knuckle race over the next three weeks with the Brotherhood mobilising its well-oiled machine to get the vote out for Morsi while the army and police are likely to support Shafiq – despite their official neutrality. On Friday the Brotherhood quickly launched an attack on Shafiq as a "fuloul" (remnant) of the old regime who was "climbing to power over the corpses of the martyrs of the revolution".

Shafiq told his supporters: "To the generous people of Egypt, justice is the rule of law."

Hisham Kassem, a publisher who had backed Moussa, said: "It's a disaster. Shafiq will try to restore the Mubarak regime. And my trust of the Brotherhood is minus zero."

Other liberals retreated into black humour. "All it takes now is for Mubarak to be released and be made vice president," one tweeted. "This is not the second republic," said another, "it's a stillborn deformity".

Zeinobia, a prominent blogger, compared the outcome to the humiliating defeat of Egypt and the other Arab states by Israel in the 1967 Middle East war. In an already tense atmosphere, there could well be serious unrest if, as some predict, Mubarak is acquitted on charges of corruption and illegal killings next month.

Assessments are divided over the likely final outcome on 16 and 17 June. Egypt's Coptic Christians will rally round Shafiq because of their visceral dislike of Islamists. Supporters of Moussa will do the same. Morsi can expect to get the votes of some who backed Hamdeen Sabbahi, the independent Nasserist candidate. But not all: "How many showers do you need to wash away a vote for the Brotherhood?" asked one progressive who refuses to back Shafiq at any price.

Hani Shukrallah, the veteran Al-Ahram journalist, called for unity. "Instead of debating the prospect of supporting one repulsive candidate or another," he wrote, "let's begin the task of putting revolutionary house in order." Morsi will also get the support of many of those who voted for Abdel-Moneim Abul Fotouh, a Brotherhood renegade and independent Islamist who, along with Moussa, had been a front-runner in recent polls. But large-scale abstentions are also likely.

"If you put the figures together it looks like Shafiq will win," said Kassem. But other analysts warned that it is always a mistake to under-estimate the Brotherhood as some did after apparent signs in recent weeks that Morsi's star was waning.

The Brotherhood already dominates Egypt's parliament, where its MPs have performed badly. It also stands accused of trying to pack the body writing a new constitution and reneging on a pledge not to compete for the presidency.

Morsi has promised a "renaissance" that will curb Mubarak-era corruption and improve the country's dilapidated infrastructure but also introduce a greater degree of rule by Islamic law. After suffering decades of repression and playing cat and mouse with the Egyptian government, the world's oldest Islamist movement senses its hour has come.

"I think we are on the verge of a new era," said the Brotherhood's Essam el-Erian. "We trusted God, we trusted in the people, we trusted in our party." Its success is part of a regional trend that has seen Islamist parties thrive as autocratic regimes, in Tunisia and Libya as well as Egypt, have fallen in the Arab spring.

Israel fears that Islamist rule in Egypt could threaten the 1979 peace treaty, which is the linchpin of US policy in the Middle East. Morsi advocates a "review" but will not scrap it. Shafiq has vowed to uphold it. Shafiq's strong performance reflected widespread worries about crime and insecurity and a yearning for stability, improvements to the economy and public services.

"Polarisation is the main characteristic of Egyptian society," said a former Liberal MP. "Shafiq did much better than Moussa because all his discourse centred on security whereas Moussa talked about economic development. But the first concern is law and order."