The announcement by election officials touched off a joyous celebration of chanting and dancing in the sweltering heat by tens of thousands of Morsi's supporters jamming Tahrir Square, the birthplace of the uprising that toppled Hosni Mubarak 16 months ago.
It also capped a week of growing political tension in the streets after authorities delayed announcing the results of the June 16-17 runoff election between Morsi and Mubarak's former prime minister, Ahmed Shafiq.
Tanks and other signs of heavy security had been deployed around the country, especially outside state institutions, in anticipation of possible violence reminiscent of the first days of last year's revolution.
President Barack Obama telephoned the U.S.-educated Morsi to congratulate him on his victory and offer continued support for Egypt's transition to democracy. The White House said Morsi expressed appreciation for Obama's call and "welcomed U.S. support for Egypt's transition."
The reaction from Israel was subdued, with Prime Minister Benjamin Netanyahu saying he respected the results of Egypt's democratic process and hoped the peace agreement between the two countries would remain intact. Ecstatic residents in the Hamas-ruled Gaza Strip filled the streets, fired guns in the air and handed out candy.
Speaking on Egyptian television Sunday evening, Morsi declared he had a "message of peace. We will respect all international agreements." He did not mention Israel but the remark seemed to be a reassuring nod to respecting the peace treaty.
The election commission said Morsi won 51.7 percent in the runoff - a margin of only 800,000 votes - over Shafiq, a former air force colonel who was perceived to be the favorite of the military council that took over from Mubarak.
"I tell everybody in this memorable day, that because of your choice, your will, and after God's favor, I am a president for all Egyptians," the 60-year-old engineer, professor and former lawmaker said in his speech, delivered stiffly as he read from notes.
Monday's editions of Freedom and Justice, the Muslim Brotherhood's newspaper that bears the same name as the group's political party, bannered the headline: "The street explodes with joy, the people write history: Morsi President of Egypt."
It was a stunning victory for the Muslim Brotherhood, a group that was outlawed under Mubarak. But the liberal and secular youth groups that drove the uprising were left wondering whether Egypt has taken a step toward becoming a repressive Islamist state, or a new power sharing agreement between Morsi and the military - the traditional power brokers.
"This is not the best scenario I anticipated," said Sarah Kamal, a liberal activist who was in Tahrir Square when Morsi's victory was announced. She ululated and cheered for him despite criticism from many of her friends that Morsi would endanger a secular Egypt.
"I know they have sold the revolution short before. But they are better than the 'felool,'" she said, referring to the remnants of the old regime. "I will stand with the Brotherhood against the military for now, and later I will fight off the Brotherhood's hold," she added.
In his speech, Morsi sought to reach out to the activists by paying tribute to the nearly 900 protesters killed in the uprising. "I wouldn't have been here between your hands as the first elected president without ... the blood, the tears, and sacrifices of the martyrs," he said.
A week ago, when the polls were closing in the runoff election, the Supreme Council of the Armed Forces (SCAF) issued constitutional amendments that stripped the president's office of most of its major powers. The ruling generals made themselves the final arbiters over the most pressing issues still complicating the transition- such as writing the constitution, legislating, passing the state budget- and granted military police broad powers to detain civilians.
A court earlier dissolved the freely elected parliament, which was dominated by the Muslim Brotherhood, leaving the military also in charge of legislating.
According to the constitutional declaration, the new president won't appoint the defense minister and will lose the title of "Supreme Commander of the Armed Forces."
Tens of thousands of Morsi's supporters vowed to stay in the square, pressing for the reversal of those actions by the generals. Mohammed el-Beltagy, a leading member of the Brotherhood and former lawmaker, said the protesters would not leave until the military fulfills its promises to hand over power to a civilian president by July 1.
"The military council must live up to these demands or it would be reneging on its promises, he told Misr 25, the Brotherhood's TV station. "We are against any confrontation, or violence, or clashes or obstruction of state institutions. We are a peaceful revolution that will insist on meeting its demands."
The defiant tone of el-Beltagy highlighted the fine line the 84-year-old Muslim Brotherhood group has had to tread amid high expectations from a president with little authority and a powerful adversary.
Ahmed Abdel-Attie, a Morsi campaign manager, told state TV that Field Marshal Hussein Tantawi, the head of the military council, called Morsi to congratulate him and that the two will meet Monday.
The military's moves had drawn international condemnation from human rights groups and the U.S., raising fears that the generals wanted to undercut Egypt's democratic experience and entrench military rule.
The ultra-conservative Salafi party Al-Nour has mediated between the Brotherhood and the military to ensure a "smooth gradual transition," said Youssri Hamad, a spokesman for the group. Hamad didn't discuss details of the mediation but he said this was in part behind the delay in announcing the election results.
The armed forces have been the source of power in Egypt since a military coup in 1952. Since then, it has acquired vast economic interests - giant construction companies, farms, water-bottling facilities and a nationwide chain of gas stations- as well as leading government posts. Civilian oversight has been one of the demands of the revolutionary groups.
The Brotherhood still controls the panel that has been given the task of writing the constitution, although the military-drafted declaration allows the generals to object to any article in it or form a new panel altogether if the panel is unable to continue its work. Liberals and secular activists have accused the Islamists of trying to dominate the writing of the new charter. There are also concerns the new constitution may try to limit the political role of the military.
Morsi also faces enormous challenges of improving the economy and maintaining law and order - both of which deteriorated in the post-Mubarak period.
Pro-democracy leader Mohammed ElBaradei urged unity after the results were announced.
"It is time we work all as Egyptians as part of a national consensus to build Egypt that is based on freedom and social justice," he wrote on his Twitter account.
Naguib Sawiris, a Coptic Christian business tycoon who joined a liberal bloc in voicing opposition to the Muslim Brotherhood on Saturday, said he expects Morsi to send a reassuring message to Egypt's Christian minority who represent around 10 percent of the population of 85 million.
"There are fears of imposing an Islamic state ... where Christians don't have same rights," Sawiris told the private TV station CBC. Morsi "is required to prove the opposite. ... We don't want speeches or promises, but in the coming period, it is about taking action. ... He was not our choice but we are accepting it is a democratic choice."
This is the first time modern Egypt will be headed by an Islamist and by a freely elected civilian. The last four presidents in the past six decades have all come from the ranks of the military.
"Before the revolution, we were forced to choose between Mubarak's ruling party and the Muslim Brotherhood (as the opposition). The revolution was about creating a third power, the people ... who are not seeking power but are seeking real change in the dynamics of power in Egypt," said Lobna Darwish, an activist who boycotted the elections.
"I am happy the Brotherhood won because now the revolution will continue on the street against both of them, the Brotherhood and the SCAF," she said.
Khaled Abdel-Hamid, a leading leftist politician, said Morsi also needs to address the issue of meting out justice to former regime officials implicated in the killings of protesters in the uprising. Mubarak, 84 and in ill health, is serving a life sentence in prison for his role.
AP writers Maggie Michael in Cairo, Robert Burns in Washington, Josef Federman in Jerusalem, and Ibrahim Barzak in Gaza City, Gaza Strip, contributed to this story.