That pointed to a potential struggle over spheres of authority between Egypt's two strongest forces. The Brotherhood has campaigned on a platform of bringing Egypt closer to a form of Islamic rule, but the military's grip puts it in a position to block that. Instead any conflict would likely center on more basic questions of power.
In a victory speech at his campaign headquarters, Morsi clearly sought to assuage fears of a large sector of Egyptians that the Brotherhood will try to impose stricter provisions of Islamic law. He said he seeks "stability, love and brotherhood for the Egyptian civil, national, democratic, constitutional and modern state" and made no mention of Islamic law.
"Thank God who led successfully us to this blessed revolution. Thank God who guided the people of Egypt to this correct path, the road of freedom, democracy," the bearded, 60-year-old U.S.-educated engineer declared.
He vowed to all Egyptians, "men, women, mothers, sisters, laborers, students ... all political factions, the Muslims, the Christians" to be "a servant for all of them."
"We are not about taking revenge or settling scores. We are all brothers of this nation, we own it together, and we are equal in rights and duties."
Final official results are due on Thursday, and the Shafiq campaign challenged the Brotherhood's victory claim, saying it was "deceiving the people." A campaign spokesman on the independent ONTV channel said counting was still going on with 19 of 27 provinces completed and Shafiq slightly ahead so far.
The Brotherhood's declaration was based on results announced by election officials at individual counting centers, where each campaign has representatives who compile the numbers and make them public before the formal announcement. The Brotherhood's early, partial counts proved generally accurate in last month's first round vote.
The group said Morsi took 51.8 percent of the vote to Shafiq's 48.1 percent out of 24.6 million votes cast, with 98 percent of the more than 13,000 poll centers counted.
At their campaign headquarters, the Brotherhood officials and supporters were ebullient over the turn of fate: The fundamentalist group that was banned for decades and repeatedly subjected to crackdowns under Mubarak's rule now held the chair that their nemesis was ousted from by last year's 18 days of mass protests. The uprising was launched by secular, leftist young activists, joined only later by the Brotherhood's leadership as millions took to the street, seeking an end to the authoritarian, corrupt regime.
Now some in Brotherhood were ready to challenge the generals. "Down with military rule," the supporters chanted.
The Arab Spring uprisings have brought greater power to Islamists in the countries where longtime authoritarian leaders were toppled but Eygpt is the only one to have an Islamist president. The Islamist Ennahda party won elections in Tunisia for a national assembly and it leads a coalition government, but the president is a leftist. Libya's leadership remains in confusion and there is no president, though Islamists play a strong role, and an Islamist party is part of the coalition government in Yemen.
The question now will be how a Brotherhood president will get along with the military generals who have ruled since Mubarak fell on Feb. 11, 2011 and who will still hold powers that can potentially paralyze Morsi. The Brotherhood has reached accommodations with the generals at times over the past 16 months, as it struck deals with Mubarak's regime itself gaining it a reputation among critics as willing to sell out for a taste of authority.
But after a highly polarized presidential election and the miltary's arrogation of powers to itself, the Brotherhood presented itself as willing to get into a confrontation with the Supreme Council of the Armed Forces, the body of top generals headed by Field Marshall Hussein Tantawi, Mubarak's defense minister for 20 years.
Just before the election, the Supreme Council of the Armed Forces, which has ruled since Mubarak's fall, slapped de facto martial law on the country, giving military police and intelligence agents the right to arrest civilians for a host of suspected crimes, some as secondary as obstructing traffic. Then came Thursday's ruling by the Supreme Constitutional Court dissolving parliament, followed by the interim constitution declaration just after polls closed Sunday following two days of voting.
According to a copy of the document obtained by The Associated Press, the generals would be the nation's legislators and control the budget.
The president will be able to appoint a Cabinet and approve or reject laws. Notably, the declaration prevents him from changing the make-up of the military council and gives Tantawi the commander-in-chief powers that previously went to the president.
The generals will also name the 100-member panel tasked with drafting a new constitution, thus ensuring the new charter would guarantee them a say in key policies like defense and national security as well as shield their vast economic empire from civilian scrutiny.
Under the document, new parliament elections will not be held until a new constitution is approved, meaning an election in December at the earliest. In the constitution-writing process, the military can object over any articles and the Supreme Constitutional Court which is made up of Mubarak-era appointees will have final say over any disputes.
"In freezing the SCAF's current membership in place and giving it such sweeping powers, the provisions really do constitutionalize a military coup," Nathan Brown, a professor of political science and international affairs at George Washington University, said in an e-mail.
Earlier Sunday, the Brotherhood's speaker of parliament Saad el-Katatni met with the deputy head of the military council, Chief of Staff Gen. Sami Anan and told him the group does not recognize the dissolution of parliament, according to a Brotherhood statement that pointedly referred to el-Katatni by his title.
El-Katatni insisted the military could not issue an interim constitution and that the constituent assembly formed last week would meet in the "coming hours" to go ahead with its work in writing the permanent charter.
Still, the Brotherhood has no power to force recognition of the parliament-created constituent assembly, which already seems discounted after parliament's dissolution and is likely to be formally disbanded by a pending court ruling. Lawmakers are literally locked out of parliament, which is ringed by troops.
The generals, mostly in their 60s and 70s, owe their ranks to the patronage of Mubarak. All along, activists from the pro-democracy youth groups that engineered the anti-Mubarak uprising questioned the generals' will to hand over power, arguing that after 60 years of direct or behind-the-scenes domination, the military was unlikely to voluntarily relinquish its perks.
The presidential race was a bitter one.
Shafiq, a former air force commander and an admirer and longtime friend of Mubarak, was seen by opponents as an extension of the old regime that millions sought to uproot when they staged a stunning uprising that toppled the man who ruled Egypt for three decades.
Morsi's opponents, in turn, feared that if he wins, the Brotherhood will take over the nation and turn it into an Islamic state, curbing freedoms and consigning minority Christians and women to second-class citizens.
Trying to rally the public in the last hours of voting, the Brotherhood presented a Morsi presidency as the last hope to prevent total control by the military council of Mubarak-era generals.
"We got rid of one devil and got 19," said Mohammed Kanouna, referring to Mubarak and the members of the military council as he voted for Morsi after night fell in Cairo's Dar el-Salam slum. "We have to let them know there is a will of the people above their will."
But the prospect that the generals will still hold most power even after their nominal handover of authority to civilians by July 1 has deepened the gloom, leaving some feeling the vote was essentially meaningless.
"Things have not changed at all. It is as if the revolution never happened," Ayat Maher, a 28-year-old mother of three, said as she waited for her husband to vote in Cairo's central Abdeen district. She said she voted for Morsi, but did not think there was much hope for him.
"The same people are running the country. The same oppression and the same sense of enslavement. They still hold the keys to everything."
AP correspondents Hamza Hendawi and Maggie Michael contributed to this report.