Mohamed Morsi of the Muslim Brotherhood sets about building a civilian administration for Egypt that can heal a divisive history of oppression and coax a mistrustful army into relaxing its grip on power.
Behind the scenes, talks were already under way between the Islamists and generals to resolve disputes that blew up this month over steps by the ruling military council to hem in the powers of the first freely elected president Egypt has known.
Cairo's Tahrir Square, theatre of the revolution that ousted Hosni Mubarak, exploded in joy - and relief - on Sunday as Morsi was declared the narrow but convincing winner of last weekend's presidential run-off against Ahmed Shafiq, another scion of the military establishment which has ruled Egypt for 60 years.
The celebrations continued through an unforgettable night after Morsi won by 3.5 percentage points or some 880,000 votes.
Those in Egypt and beyond who feared a win for Shafiq might have spelled the end of the Arab Spring acknowledged a triumph for the popular will, and for the army which accepted it. From Syria's opposition came word that Cairo was again a "source of hope" for a people "facing a repressive war of annihilation."
But beyond the vast throng who waved their flags and chanted praises to God for hours on end on Tahrir Square, millions of Egyptians, and the Western powers, looked on with unease at the prospect of the long-suppressed Brotherhood making good on its dream of an Islamic state for the Arab world's biggest nation.
Among the most anxious were the young, urban revolutionaries who launched last year's uprising but saw their representatives knocked out in last month's first round vote, as well as diehard supporters of the old regime who fear for their privileges. Some Shafik admirers wept in fury that the army had "betrayed" them.
Morsi, a 60-year-old engineer who studied in California and was jailed for his politics by Mubarak's secret police, took his first steps in public to quell some fears: "I am today a president for all Egyptians," he said in an address after what he called "this historic moment, this luminous moment."
He repeated his respect for international treaties - a gesture to Israel, which has fretted about its 1979 peace deal, and to Egypt's army, whose big US subsidy depends on it.
Barack Obama called him. "The president underscored that the United States will continue to support Egypt's transition to democracy and stand by the Egyptian people as they fulfill the promise of their revolution," the White House said.
The bearded Morsi, smiling occasionally, echoed that in his televised speech, saying he would work with others to see the democratic revolution through: "There is no room now for the language of confrontation," he said.
Morsi, an obscure party official before being catapulted to prominence by the disqualification of the movement's preferred candidate, has little choice but to compromise, and sources in the Brotherhood said a package of agreements, already discussed with senior generals last week, could soon be announced.
At daggers drawn for most of Egypt's modern history, the Brotherhood, an international model for many Islamist parties, and the army were drawn into a wary symbiosis once the military council pushed out Mubarak to appease the protesters and found in its long-banned enemy the most organized political force.
The Brotherhood, conscious of playing a long game, was ready to play its part in a transition. But cooperation frayed when the Islamists made a push for more control. They secured the lion's share in a parliament elected in January and, with the influence that offered over drafting a constitution, plus the presidency, would have been very much in the driving seat.
That was clearly too much for Field Marshal Hussein Tantawi and his Supreme Council of the Armed Forces. With the help of a Mubarak-era judiciary, SCAF dissolved parliament on the eve of the presidential election and then gave itself the legislative power, adding also a potential role in forming a panel to write the constitution. It also revived some powers for martial law.
Critics at home and in the West called it a "soft coup."
Senior Brotherhood officials say they have been negotiating in the past week to change some of that. Though both sides deny that any deal was struck over the result of the presidential vote itself, Morsi's election now sets a key reference point around which a power-sharing compromise can be built while the process of constructing a constitutional democracy goes on.
"President Morsi and his team have been in talks with the military council to bring back the democratically elected parliament and other issues," Essam Haddad, a senior Brotherhood official, told Reuters on Monday.
Brotherhood sources told Reuters they hoped the army might allow a partial recall of parliament and other concessions in return for Morsi exercising his powers to name a government and presidential administration in ways the army approves of - notably by extending appointments across the political spectrum.
Military officials have confirmed discussions in the past few days but had no immediate comment on the latest talks.
The Brotherhood has, movement officials said, approached secular reformist politician Mohamed ElBaradei, a former UN diplomat and Nobel peace laureate, to take a senior post, possibly as prime minister. ElBaradei has not commented.
Brotherhood officials have said they will press on with street protests to pressure the army but this, along with a number of other contentious issues including to whom and where Morsy swears his oath of office, could be settled soon.
The army wants Morsi sworn in on June 30, meeting a deadline it set itself for handing over Egypt to "civilian rule."
"Nobody should doubt there is going to be deal-making," said analyst Shadi Hamid, director of the Brookings Doha Center. "The (SCAF) still has the tanks and guns and the Brotherhood still understands that. There has to be some temporary power-sharing agreement. There has to be give and take."
Morsi, who evaded questions during his campaign on such fraught issues as dress codes on Egypt's profitable tourist beaches, peppered his address with religious language as he spoke from a lectern blazoned with the presidential seal - a jarring mix of sights and sounds for the vast majority Egypt's 82 million people who can remember no president but Mubarak.
He has promised a moderate "Islamic renaissance" for an Egypt mired in economic crisis. Supporters cite the example of Turkey, where the party now led by Prime Minister Tayyip Erdogan slowly eroded the army's resistance to pious politicians and the Muslim country has emerged as a political and economic force.
But Morsi, and the party grandees behind him, are aware that without cooperation from both the army, and the wider "deep state" of business and institutional vested interests built up under military rule, the Brotherhood risks accepting a poisoned chalice, enjoying the outward trappings of power but taking all the blame when life does not improve as fast as people hope.
Describing the election as "a true example of democracy to the world" a military council source said the pressure was on Morsi: "The onus now is on the new president to unite the nation and create a true coalition of political and revolutionary forces to rebuild the country economically and politically.
"The world is now watching the new president."
Calling it a "milestone in their transition to democracy," the United States, the army's key sponsor and also long wary of the rise of political Islam, joined other Western powers in congratulating Morsi and calling on him to form a government of national unity that would respect all Egyptians' civil rights, notably those of women and the 10-percent Christian minority.
The White House said: "It is important for President-elect Morsy to take steps at this historic time to advance national unity by reaching out to all parties and constituencies in consultations about the formation of a new government."
The British and French governments echoed that sentiment.
Israel is at war with the Brotherhood's Palestinian offshoot Hamas, which celebrated Morsi's win in Gaza. Israeli Prime Minister Benjamin Netanyahu said he "respected" the result and expected to continue cooperation under the peace treaty.
Half of those who voted in last month's first round of the election backed neither Morsi nor Shafiq and many who voted in the run-off voted negatively - either against Morsi's religious agenda or against Shafik as a symbol of military rule.
"We voted for Morsi reluctantly to prevent Shafiq from getting in because if he were president, we would all be hanged," said Mohamed Abdel Latif, 28, a youth activist in the second city of Alexandria. "From today, we will oppose Morsi.
"The Brotherhood must remember that they won because of us and they shouldn't repeat the mistakes of the past."
Shafiq, a former air force commander and Mubarak's last prime minister, offered his congratulations and said he was willing to serve in Morsi's administration if asked.
He had the support of many Christians, who reacted gloomily to his defeat. Ehab Aziz of the Coptic American Friendship League said they were worried they would face special taxes, as some interpretations of Islamic law suggest for non-believers.
Joe Fahim, 29, a Christian in Cairo, said he was personally uncertain but added: "For most Copts though, it's doomsday."