The Muslim Brotherhood's Mohamed Morsi has officially won Egypt's presidential election and will be the country's next president, the electoral commission has announced.
Morsi picked up 13.2 million votes out of just over 26 million, giving him about 51 per cent of the vote. His competitor, Ahmed Shafik, the final prime minister under Hosni Mubarak, received 12.3 million. More than 800,000 ballots were invalidated.
The president-elected delivered a victory address on Sunday night. He spoke on state television, long a medium which demonised him and the Muslim Brotherhood. He thanked the Egyptian people for their votes, calling them "my family" and "my beloved," and promised to work to "restore their rights."
"I have no rights, only responsibilities," Morsi said. "If I do not deliver, do not obey me."
He also reached out to the army, the police, and Egypt's intelligence services, thanking them for their work in protecting the country, and promised to "preserve" the military.
Congratulations from abroad
Tens of thousands of people flocked to Tahrir Square to celebrate Morsi's victory, where they waved Egyptian flags and chanted "God is great" and "down with military rule."
Mohamed Hussein Tantawi, Egypt's military ruler, congratulated Morsi on his victory, state television reported. Reactions also trickled in from around the region: The governments of Turkey, the United Arab Emirates, and the Palestinian Authority congratulated the winner.
Binyamin Netanyahu, the Israeli prime minister, said in a statement that he "respects the outcome" of the election, and "expects to continue cooperation with the Egyptian administration". Morsi made an oblique reference to Israel in his victory speech, when he promised to "keep all international treaties," a vow which would include the 1979 Camp David Accords between Israel and Egypt.
The White House also congratulated Morsi, and urged him to "advance national unity by reaching out to all parties and constituencies."
Bishop Pachomius, the caretaker pope of Egypt's Coptic Church, issued a short statement congratulating Morsi. The Coptic community makes up about 10 per cent of Egypt's population, and some were worried by Morsi's candidacy, fearing that his government would restrict their personal freedoms.
Gehad el-Haddad, Morsi's campaign spokesman, said in an interview shortly after the results were announced that Morsi would work to be a "president for all Egyptians".
The president-elect is expected to take his oath of office later this month in front of the country's supreme court - though a spokesman said on Facebook that Morsi would take the oath in front of parliament, the "only elected institution" in the country.
The Muslim Brotherhood said in a statement that Morsi had resigned his positions in both the Brotherhood and its Freedom and Justice Party, fulfilling a campaign pledge.
There was no immediate reaction from Shafik's campaign.
Political uncertainty ahead
Morsi's victory caps off more than a week of behind-the-scenes negotiations between the Brotherhood and the ruling Supreme Council of the Armed Forces (SCAF). He claimed victory just hours after last week's runoff election, based on unofficial numbers tallied by the Brotherhood, but the commission delayed its official announcement until Sunday.
In the intervening days, Khairat al-Shater, the Brotherhood's political boss, met generals from SCAF at least once. Sources say they were negotiating exactly what powers the president will have.
Despite Morsi's victory, many of those questions about his power remain unanswered.
"This is not the end of the game, it's a start of a huge responsibility," el-Haddad told Al Jazeera.
"It comes with more challenges, turning from being the largest opposition group in Egypt to leading the country with its national front."
Morsi retains the right to appoint the prime minister and cabinet. He has already begun talks o form a presidential team and cabinet that "would truly represent Egypt after the revolution," according to a statement on the Brotherhoods Twitter account.
Shortly before the polls closed last week, the generals issued a decree sharply limiting the powers of the new president. It permitted him to declare war, for example, only with the approval of the military council.
SCAF will also keep control of legislative power, and the budget, until a new parliament is elected. Egyptians went to the polls in November to elect a legislature, which was dominated by the Freedom and Justice Party, but it was dissolved earlier this month after a high court ruling found parts of the electoral law unconstitutional.
Saad el-Katatni, the speaker of the now-dissolved parliament, also met with officials from SCAF, and told them that the Brotherhood would not accept the court ruling or the election-night decree. But it is unclear whether the Brotherhood ultimately accepted those decisions in exchange for the presidency.
Either way, the military council - which has promised to hand over power to a civilian government on June 30, in a "grand ceremony" - will remain a powerful force in Egyptian politics, despite the election of a civilian president.
Comments on this story? Share your thoughts below.
Al Jazeera and agencies