AFP - Muslim Brotherhood member Mohamed Morsi was on Sunday declared the first president of Egypt since a popular uprising ousted Hosni Mubarak, capping a tumultuous and divisive military-led transition.
Morsi, who ran against Mubarak-era minister Ahmed Shafiq, won 51.73 percent of the vote after a race that had polarised the nation.
"The winner of the election for Egyptian president on June 16-17 is Mohamed Morsi Eissa al-Ayat," said head of the electoral commission Faruq Sultan.
Live from Tahrir square
I've met people who boycotted the election altogether. They say they're not so happy that Morsi has won, but they're prepared to give him a chance.
Morsi's victory marks the first time Islamists have taken the presidency of the Arab World’s most populous nation, but recent moves by the ruling military to consolidate its power have rendered the post toothless.
Thousands of Morsi supporters who had packed into Cairo's Tahrir Square erupted in celebration, waving flags and posters of the Islamist leader.
"God is greatest" and "down with military rule" they chanted as some set off firecrackers minutes after the electoral commission formally declared the result.
Across Cairo, cars sounded their horns and chants of "Morsi, Morsi" were heard.
Morsi won with 13,230,131 votes against Shafiq's 12,347,380, Sultan said. The election, in which more than 50 million voters were eligible to cast their ballot, saw a 51.8 percent turnout.
Military ruler Field Marshal Hussein Tantawi, who took power when Hosni Mubarak was forced to resign in February last year, congratulated Morsi on his win, state television announced.
Morsi says he'll be "president for all Egyptians"
Egypt's Mohamed Morsi, the first Islamist to be elected president of the Arab world's most populous nation, said Sunday he will be a leader "for all Egyptians" and called for national unity after a polarising race.
"I call on you, great people of Egypt ... to strengthen our national unity," he said, adding that national unity "is the only way out of these difficult times".
Morsi, who resigned from the Muslim Brotherhood to take the top job, thanked the "martyrs" of the uprising for the victory and stressed that "the revolution continues".
The 60-year-old engineer also vowed to honour international treaties.
"We will preserve all international treaties and charters ... we come in peace," Morsi said.
Shafiq supporters who had gathered to hear the result with his campaign team in the suburbs of Cairo were devastated by the result.
Some women screamed and others cried as several men held their heads between their hands in despair.
"It's a very sad day for Egypt. I don't think Morsi is the winner, I'm very sad that Egypt will be represented by this man and this group," Shafiq supporter Maged told AFP after the result.
The capital was tense before the announcement, with the city's notoriously busy streets deserted and shops and schools closed.
Extra troops and police were deployed as military helicopters flew overhead.
The road to parliament was closed to traffic, and security was tightened around vital establishments as Egyptians waited nervously for the result.
The election has polarised the nation, dividing those who feared a return to the old regime under Shafiq from others who wanted to keep religion out of politics and who fear the Brotherhood would stifle personal freedoms.
Shafiq ran on a strong law-and-order platform, pledging to restore security and stability. He is himself a retired general, but as a Mubarak-era minister he is reviled by the activists who spearheaded the 2011 revolt.
President-elect Morsi was the Islamists' fallback representative after their deputy leader Khairat El-Shater was disqualified.
In campaigning he sought to allay the fears of secular groups and the sizeable Coptic Christian minority by promising a diverse and inclusive political system.
On Saturday, two massive Cairo protests duelled for supremacy.
Thousands of Brotherhood supporters thronged Tahrir Square, with hundreds spending the night there. "Morsi, Morsi, God is the Greatest," they chanted.
Across the city in the Nasr City neighbourhood, thousands of Shafiq supporters held up pictures of him and of Tantawi, chanting: "The people and the army are one."
"Down with the rule of the Supreme Guide," they shouted, referring to the head of the Muslim Brotherhood.
Both Morsi and Shafiq had claimed victory in the election for a successor to Mubarak, and tensions heightened after the electoral commission delayed announcing the official outcome.
The delay in announcing the result of the June 16-17 run-off, initially scheduled for Thursday, had raised raised suspicions that the outcome of the election was being negotiated rather than counted.
On Friday, the SCAF warned it would deal "with utmost firmness and strength" with any attempts to harm public interests.
The Brotherhood warned against tampering with the election results, but also said it had no intention of instigating violence.
It has rejected a constitutional declaration by the military that strips away any gains made by the Islamist group since the popular uprising which forced Mubarak to stand down in February last year.
The document dissolves the Islamist-led parliament and gives the army a broad say in government policy and control over the new constitution. It was adopted just days after a justice ministry decree granted the army powers of arrest.