Updated

The new Egyptian president Mohammed Morsi moved first thing Monday morning into the office once occupied by his ousted predecessor Hosni Mubarak and started work on forming a government even before he had a clear picture of what he could do after the ruling military stripped most of the major powers from his post.

The country breathed a sigh of relief that at least the question of who won the presidential runoff had been resolved on Sunday after the first free and fair elections in Egypt's modern history. People returned to work a day after a panic that sent many home early for fear that violence might erupt when the winner was announced. Traffic was flowing again through Cairo's Tahrir Square, the birthplace of last year's uprising and a major intersection that had been blocked for nearly a week by Morsi supporters protesting against the military's power grab.

Egypt's benchmark stock index closed with record gains of 7.5 percent in a sign of optimism after a president was named. And newspapers were brimming with upbeat headlines, after a week of rumors and scaremongering. "Morsi president on orders from the people: The revolution reaches the presidential palace," said a banner headline in independent daily Al-Shorouk.

"His priority is the stability on the political scene," said Yasser Ali, a spokesman for Morsi who said the president was in his office to consult on forming a new government and choosing his team.

Morsi, from the fundamentalist Muslim Brotherhood group, is the first Islamist president of Egypt. He defeated Mubarak's last prime minister, Ahmed Shafiq, in a tight race that deeply polarized the nation.

More On This...

    Now he faces a daunting struggle for power with the still-dominant military rulers who took over after Mubarak's ouster in the uprising.

    The 60-year-old, U.S.-trained engineer comes into office knowing little about his authorities and what he can do to resolve security and economic crises and meet the high expectations for the country's first popularly elected leader.

    The contours were emerging of a backroom deal between the military and the Brotherhood that led to the ruling military council blessing Morsi as president. One mediator said negotiations are still under way to hammer out political understandings.

    State TV showed footage of Morsi meeting Monday with the ruling military council headed by Field Marshal Hussein Tantawi, who was Mubarak's defense minister for 20 years. The TV quoted Tantawi as saying the military will "stand by the elected, legitimate president and will cooperate with him for the stability of the country."

    Morsi also met with the military-backed Prime Minister Kamal el-Ganzouri, who resigned Monday and was asked to head a caretaker government until Morsi nominates a new one.

    Emad Abdel-Ghaffour, the head of the ultraconservative Islamist party Al-Nour, said in the week between the June 16-17 presidential runoff and the announcement of the winner on Sunday, many politicians tried to mediate between the Islamists and the generals to defuse a political crisis.

    "There was an easing (of tension)" when the elections results came through, he said. But discussions are still under way to clarify the authorities of the president and the military. And one of the immediate sticking points is the dissolution of the Muslim Brotherhood-dominated parliament by a court order, days before the presidential runoff.

    As polls closed on June 17, the ruling Supreme Council of the Armed Forces announced constitutional amendments that shocked the Brotherhood and many other political activists who took part in the uprising 16 months ago.

    The ruling generals gave themselves sweeping powers that undercut the authority of the president. That followed a government decision that granted military police broad powers to detain civilians. The military council, which promised to transfer power to an elected leader by July 1, said the moves were designed to fill a power vacuum and ensure that the president doesn't monopolize decision-making until a new constitution is drafted.

    Two days before the runoff, a court packed with judged appointed by the Mubarak regime also dissolved the country's first freely elected parliament. The military council followed by declaring it was now in charge of legislating.

    Closed-door meetings between Brotherhood members and the ruling generals as well as mediation from different groups, including pro-reform leader Mohammed ElBaradei, aimed at easing the crisis and defusing a political stalemate.

    Brotherhood members said the election results, delayed for four days, were held up by authorities as a bargaining chip to reassure the generals in the face of mounting Brotherhood opposition to the military's tightening grip and the group's rise to power.

    Former presidents were sworn in by parliament. But with the parliament dissolved, it was not clear where Morsi will be sworn in. Authorities say he could be sworn before the country's highest court, but his supporters are pressing for parliament to be reinstated, arguing that the court decision only disputed a third of the house's seats.

    Abdel-Ghaffour said discussions with the generals centered on the Brotherhood's argument that only the disputed third of parliament be dissolved because it was that portion that was elected based on articles deemed unconstitutional. Independent and party members competed for a third of the 498-seat house, which the court said violated rules of equality between candidates.

    Brotherhood lawyers say another court, Egypt's highest administrative court, is likely to back their claim.

    "This is likely to happen," said Abdel-Ghaffour, whose Islamist party won 25 percent of the dissolved parliament seats in addition to the Brotherhood's nearly 50 percent. "A third of parliament can be dissolved and re-elected in 75 days."

    The speaker of the dissolved parliament met with the No. 2 general on the military council, Chief of Staff Gen. Sami Anan, twice since the court decision on June 14.

    Abdel-Ghaffour also said talks centered on reassurances the generals were seeking regarding the Brotherhood's control of the new government, including demands that Morsi appoint a prime minister who is a technocrat from outside the Brotherhood.

    The stickier issue of drafting the constitution was also raised as well as fears over who controls the key foreign and defense ministries. The generals' new declaration ensures the military appoint the defense minister and control all issues regarding military personnel.

    Before parliament was dissolved, a panel appointed by the legislature was supposed to be in charge of drafting the new constitution which would determine the role of Islam in legislation, Egypt's future political system and the role of the military.

    In the recent power grab, the ruling generals gave themselves, the prime minister, judges or a fifth of the panel members the right to veto details of the constitution that will be drafted, curbing the powers of Islamists to control the process. The parliament-formed panel is expected to meet Tuesday, and Abdel-Ghaffour said it is expected to continue its work.

    "Both sides want reassurances," Abdel-Ghaffour said. "But there is a will for the caravan to keep moving," he said, using an Arabic expression.

    In his first speech after being named president, Morsi called for national unity and pledged he will be a "president for all Egyptians." In an effort to heal national divisions, he vowed to appoint diverse deputies including a woman and a Christian. He also has reached out to other presidential hopefuls who got significant support in the first round of elections.

    His spokesman Ali said Morsi wants to form a national coalition government that will bring in technocrats and representatives of a broad variety of political factions. But that is likely to take time, Ali said.

    Thousands of Morsi supporters, backed by some liberal and secular youth groups who drove the uprising, vowed to press on with their protest in Tahrir Square to pressure the ruling generals to rescind their decrees and reinstate parliament. Tens of thousands spent the night in Tahrir in joyous celebration of Morsi's win. But by morning, the crowds had thinned considerably.

    But Brotherhood officials said the protests will continue until the military responds to their demands.

    Morsi faces enormous challenges of improving the economy and maintaining law and order -- both of which deteriorated in the post-Mubarak period. His victory is a stunning achievement for the Muslim Brotherhood, a shadowy organization repressed by successive regimes.

    He is Egypt's first civilian president -- his four predecessors all came from the ranks of the military.