CAIRO — As Mohammed Morsi moved into the presidential office last occupied by Hosni Mubarak, the contours emerged Monday of a backroom deal that led Egypt’s powerful military council to bless the Islamist as the country’s first freely elected head of state.

The complex web of issues still to be worked out range from what to do about the dissolved parliament and the drafting of a new constitution to who will head the Cabinet and hold the key defense and foreign ministries.

After the generals stripped the presidency of most of its major powers in recent weeks, Morsi takes office without a clear picture of his authorities or what he can do to resolve Egypt’s most pressing issues, including restoring stability and improving the struggling economy.

Morsi narrowly defeated Ahmed Shafiq, Mubarak’s last prime minister and a former air force general, in a race that deeply polarized the nation and threatened to unleash violent protests.

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

Lawmakers and mediators acknowledged that talks with the generals took place last week and are ongoing — a sign that much remains undone.

“There is a political settlement initiative that takes everyone’s concerns into account,” said Muslim Brotherhood member and lawmaker Sobhi Saleh.

But deep mistrust remains. The ruling generals have stacked their side with a maze of legal tools that strengthen their negotiating position, while the Brotherhood must tread softly: The talks can easily blow up into wider social discontent if the Islamist group appears to be looking out only for its own partisan interests and trying to entrench its grip on power.

Emad Abdel-Ghaffour, 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 Sunday, many politicians tried to mediate between the Islamists and the generals.

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.