WASHINGTON (AP) — The election of an Islamist president in Egypt turns longstanding US policy in the Mideast inside out: The Obama administration is relieved that the candidate representing three decades of close partnership with the United States lost.

The US is now set to embrace a religious-based former opposition leader who does not share many goals, perhaps including the 30-year peace with Israel upon which US policy in the region is based.

The administration is calling the election of Mohammed Morsi on Sunday a milestone in the transition to democracy.

Morsi, from the formerly banned fundamentalist Muslim Brotherhood group, is the first Islamist president of Egypt. He defeated Ahmed Shafiq, the ousted President Hosni Mubarak’s last prime minister, in a tight race that deeply split the nation.

Now Morsi faces a struggle for power with the still-dominant military rulers who took over after Mubarak was forced out in last year’s Arab uprising.

The US mostly had held the Muslim Brotherhood at arms’ length in deference to Mubarak and long has eyed with suspicion the party’s emerging positions on Israel, women’s rights and religious freedom.

The Muslim Brotherhood has said it would seek changes to Egypt’s 1979 peace treaty with Israel without canceling it. Morsi said in his first televised speech that he would preserve Egypt’s international accords, a reference to the peace deal with Israel.

Despite reservations, the Obama administration is relieved that Morsi won without unleashing a new wave of violence and unrest, and without provoking a military coup.

Morsi was popularly elected, and the freedom of the election is more important than who won it, US officials said.

“We look forward to working together with President-elect Morsi and the government he forms to advance the many shared interests between Egypt and the United States,” White House press secretary Jay Carney said Monday. “We judge individuals and parties that are elected in a democratic process by their actions, not by their religious affiliation.”

“Our commitment to the revolution that began in Egypt … is to a process that provides for a transition to democracy that is transparent,” Carney said.

Deep concern that violence might erupt Sunday when the winner of the runoff was announced ebbed Monday.

“We want to see President-elect Morsi take steps to advance national unity, to uphold universal values, to respect the rights of all Egyptians, particularly women, minorities (and) Christians,” State Department spokeswoman Victoria Nuland said.

US officials said the administration is ready to send a senior official to Cairo to meet in person with Morsi and members of his government once his Cabinet is assembled and Washington is assured that the military has or will turn over power to the new president. Officials said full diplomatic recognition by the United States is likely once Morsi is inaugurated. The officials spoke on condition of anonymity because plans for Morsi’s inauguration were not final.

The administration had expressed no public preference in advance of Sunday’s announcement of the runoff results.

President Barack Obama made a point of calling both Morsi and the losing military-backed candidate on Sunday. He urged the military establishment to “play a role in Egyptian politics by supporting the democratic process and working to unify the Egyptian people,” the White House said.

The military leadership has committed to handing over power at the end of this month.

The United States wants Morsi to make a stronger statement of commitment to the peace deal signed at Camp David in 1979 but is settling so far for oblique references.

Nuland said the US has heard nothing from Morsi to suggest that Egypt would rethink the treaty.

“Obviously we look forward to talking to President-elect Morsi and his government about Egypt’s relationships in the neighborhood going forward, its upholding of all of its international obligations,” Nuland said.

The peace treaty with Israel is the biggest unknown posed by the rise of the Muslim Brotherhood and more fundamentalist Islamic political parties in Egypt. The treaty is broadly unpopular in Egypt, even though it is the bedrock for more than $1 billion in badly needed US aid annually. Without an autocrat to keep the treaty in place by force, its long-term fate is uncertain.

Carney had a subtle warning to the Islamists that some US support hinges on the treaty and Egypt’s role as a peacemaker and bulwark among Arab nations. Washington was willing to overlook many of Mubarak’s faults because he resisted pressure within Egypt to break the Camp David accords with Israel or loosen its alliance with the United States.

“We believe it is essential for the Egyptian government to continue to fulfill Egypt’s role as a pillar of regional peace, security and stability,” Carney said. “We will continue to emphasize this message with the new government and structure our engagement accordingly.”

The extent of Morsi’s power is not clear after the ruling military stripped most of the major powers from his post, but his victory speaks to the ebb of US influence in the Mideast now and in the future, Aaron David Miller, a Mideast scholar at the Wilson Center, said.

“For 50 years we dealt with authoritarian leaders,” across the region, Miller said, because it served practical interests to do so. Bahrain and Saudi Arabia are about all that remain autocratic and strong US allies, he noted.

“Our policies in the region are opposed by the vast majority of Arabs, and public opinion now plays a bigger role in governing,” Miller said. “Our space is going to shrink.”

Copyright 2012 The Associated Press.