Mr. Obama seemed to indicate that the American relationship with Egypt is evolving. “I don’t think that we would consider them an ally, but we don’t consider them an enemy,” he said in an interview with Telemundo that was broadcast Wednesday night on The Rachel Maddow Show on MSNBC. “I think it’s still a work in progress, but certainly in this situation, what we’re going to expect is that they are responsive to our insistence that our embassy is protected, our personnel is protected.”

For the United States, “politically the bigger issue is Egypt,” said Martin S. Indyk, a former United States ambassador to Israel. “On the one hand, you didn’t have Americans getting killed, but this was the fourth time an embassy was assaulted in Cairo with the Egyptian police doing precious little,” Mr. Indyk said. “And where was President Morsi’s condemnation of this?”

Several foreign policy experts said they worried that Mr. Morsi was putting appeasement of his country’s Islamist population ahead of national security. That comes on top of other moves by his government, including restrictions on press freedom and squabbling with Israel over how to crack down on terrorists taking root in the Sinai Peninsula.

While the killing of Mr. Stevens is a “tragedy,” said Robert Malley, Middle East and North Africa program director at the International Crisis Group, “in the longer term, Libya mainly is a problem for Libyans.” What happens in Egypt, by contrast, from “popular attitudes toward the U.S., to its domestic economy, to relations between the Muslim Brotherhood and the army, to relations between Cairo and Jerusalem, to the situation in Sinai, will profoundly affect the region, and so will profoundly affect America’s posture in the region,” he said.

What makes Egypt’s uncertain course so vexing for the White House is that Mr. Obama, more than any other foreign leader, has sided again and again with the Arab street in Cairo, even when it meant going expressly against the wishes of traditional allies, including the Egyptian military, the Persian Gulf states and Israel.

As recently as June, Mr. Obama was calling on the Egyptian military to quickly hand over power to the democratically elected civilian government — a move that helped Mr. Morsi, whose movement has called for greater use of Islamic law, assume power. At the same time, the administration was chastising the military, which has for 30 years served as the bulwark of a crucial American strategic interest in the Middle East: the 1979 Camp David peace treaty between Egypt and Israel.