Peter Baker and Mark Landler / New York Times News Service

After days of anti-American violence across the Muslim world, the White House is girding itself for an extended period of turmoil that will test the security of U.S. diplomatic missions and President Barack Obama’s ability to shape the forces of change in the Arab world.

Although the tumult subsided Saturday, senior administration officials said they had concluded that the sometimes violent protests in Muslim countries may presage a sustained crisis with unpredictable diplomatic and political consequences.

While pressing Arab leaders to tamp down the unrest, Obama and his advisers are left to consider whether to scale back diplomatic activities in the region.

The unrest has suddenly called into question central tenets of the president’s Middle East policy.

Analysts say such questions are mounting: Did he do enough throughout the Arab Spring to help the transition to democracy from autocracy? Has he drawn a hard enough line against Islamic extremists? Did his administration fail to address security concerns? Has his outreach to the Muslim world yielded any lasting benefits?

This has become Obama’s most serious foreign policy crisis of the election season. These questions come at an inopportune time domestically as Obama enters the last stages of a campaign season with a measurable lead in polls. His policies escaped serious scrutiny in the initial days after the attack that killed four Americans in Libya last week, in part because of the furor over a statement by his opponent, Mitt Romney, accusing the president of sympathizing with the attackers. White House officials said they recognized that if not for Romney’s statement, they would have been the ones on the defensive.

The Egyptian government, responding to administration pressure, cracked down on protesters in Cairo on Saturday. And the U.S. is sending more spies, Marines and drones to Libya, trying to speed the search for those who killed the U.S. ambassador and three other Americans. But the investigation there is complicated by a chaotic security picture in the post-revolutionary country and limited American and Libyan intelligence resources. The CIA has fewer people available to send, stretched thin from tracking conflicts across the Middle East, Africa and Asia. Much of the team dispatched to Libya during the revolution had been sent onward to the Syrian border, U.S. officials say.

And images from the past week of U.S. flags being torn down and burned, an Islamic flag being raised and embassies being overrun by angry mobs introduce a volatile element into a re-election effort in which foreign policy has been a strength. Some critics and commentators were already evoking the images of the Iranian hostage crisis that doomed another presidency.

“After Obama’s success in killing Osama bin Laden, in killing Gadhafi and in not blowing up Iraq, I think Obama and his aides figured we’ve got this box pretty well taken care of,” said Michael Rubin, a Middle East scholar at the American Enterprise Institute and former Bush administration official, referring to Moammar Gadhafi of Libya.

“Now that gets thrown up into the air,” he said. “Instead of Obama being the successful guy that got bin Laden, we’re talking about Obama as the second coming of Jimmy Carter, and that’s not something the campaign wants to see.”

A new relationship

Obama came to office vowing to recalibrate America’s relationship with the Muslim world after the Iraq war and gave a much-acclaimed speech in Cairo outlining a new era of fraternity. Caught off guard by cascading revolutions in the Middle East, he eventually supported rebels who overthrew Egypt’s longtime president and ordered airstrikes that helped bring down Gadhafi, who was later killed. But he has struggled to find a balance between supporting the growth of democracy and guarding national interests in the region as authoritarian governments have been replaced by popular Islamist parties, some of them unfriendly to the United States. Even to the extent that the United States supports greater democracy, it may not necessarily be able to tamp down radicalism and anti-American rage in a region with no real history of popular rule and deep economic troubles. His citing of Libya as a model now looks suspect, and the United States has been powerless to stop a bloody crackdown in Syria.

Administration officials worry that the violence in Egypt, Tunisia and other countries is likely to rage for a while, because with every new protest more people are exposed to the inflammatory American-made anti-Islam video that has fueled so much anger. Officials have studied previous outbreaks of violence, coming after the release of Danish cartoons lampooning the Prophet Muhammad or the burning of copies of the Quran by the Florida pastor Terry Jones.

“The reality is the Middle East is going to be turbulent for the foreseeable future and beyond that,” said Richard Haass, president of the Council on Foreign Relations and a former State Department official in the Bush administration. “It’s going to present the United States with any number of difficult choices. It’s also going to be frustrating because in most instances our interests are likely to be greater than our influence.”

Administration officials say Obama’s outreach has improved the position of the United States in the Muslim world. “We have made significant inroads in demonstrating that the U.S. is not at war with Islam, and isolating al-Qaida as an element within Islam,” said Benjamin J. Rhodes, a deputy national security adviser. “But it clearly remains the case that there are persistent challenges in parts of the Arab world. It’s been building up for a very long time.”

On the campaign trail

The twin challenges of dealing with the crisis overseas and the politics of it at home overlap in complicated and uncomfortable ways. Just hours after mourning the death of the U.S. ambassador to Libya, J. Christopher Stevens, and the other slain Americans last Wednesday, Obama flew off to a Las Vegas campaign event. After greeting their flag-draped coffins at Joint Base Andrews on Friday, he headed to Democratic headquarters for campaign meetings and then to an evening fundraiser.

In his weekly address on Saturday, Obama referred to American anxieties about the unrest. “I know the images on our televisions are disturbing,” he said. “But let us never forget that for every angry mob, there are millions who yearn for the freedom, and dignity, and hope that our flag represents.”

During marathon meetings at the White House since the killings of U.S. diplomatic officials in Benghazi, officials have tried to anticipate the next developments and contemplate a U.S. response. But they were caught off guard when a U.S.-run school was ransacked in Tunisia.

Even as more Marines are sent to diplomatic missions, the Obama team is confronting the very nature of America’s presence in the Middle East. With embassies already fortified after the attacks of Sept. 11, 2001, officials are asking whether they can be further secured or whether some activities need to be curtailed, like assistance and public diplomacy programs that leave Americans more exposed, though there are no plans at the moment to do so.

The trade-offs of such choices are stark. Pulling back on U.S. involvement in these countries would undercut the ability to build cultural bridges that in theory diminish the sort of hostility now vividly on display. Yet officials said continuing with business as usual seemed untenable as well, and they recognize that foreign aid, already a tough sell in a rigid fiscal environment, may become even tougher to extract from Congress.

At home, the challenge is political but no less daunting. Republicans have until now had a hard time putting up a fight on national security and foreign policy but believe the uprisings provide a new opening. Romney’s campaign characterizes Obama’s approach to the Arab Spring as naive and apologetic, and it has criticized him for not being supportive enough of Israel. In recent days, critics have accused Obama of not paying enough attention to intelligence briefings. Obama receives the presidential daily briefing in writing every day but does not always sit down with intelligence briefers for an oral presentation as President George W. Bush did. Critics like former Vice President Dick Cheney said it indicated an inattention to a dangerous world.

“The hubris of a president who believes he does not need to meet regularly with them is astounding,” Marc Thiessen, a former speechwriter for Bush, wrote in The Washington Post.

The White House says the president receives plenty of briefings and meets repeatedly with security advisers. “The president’s record, when it comes to acting on — interpreting correctly and acting on — intelligence in the interest of the security of the United States is one that we are happy to have examined,” said Jay Carney, the White House press secretary.

‘Obama did his best’

While Obama’s team says it believes that Romney’s initial attack on the president after the Middle East eruption backfired, it recognizes that a more effective critique would be to assert that the president was not wary enough of Islamist-dominated governments that rose from the ashes of secular authoritarian governments. His defenders argue that he had few options given strategic interests and a legacy of U.S. support for Arab autocrats.

“Obama did his best, in a very difficult situation, to get the United States on the right side of history,” said Martin S. Indyk, a former ambassador to Israel in the Clinton administration. “But we had a good 40 years of U.S. policy backing regimes that the people in the street overthrew.”

Some analysts faulted not Obama’s handling of the Arab Spring but his failure to make progress in peace negotiations between Israelis and Palestinians. “You didn’t have a track record to use with these Arab elites to say, ‘We’re doing the right things,’” said Daniel Kurtzer, a former ambassador to Egypt and Israel in both the Clinton and Bush administrations who teaches at Princeton.

Rubin said it might be that there was little Obama could have done differently to change the dynamics and that he suffered from an intelligence breakdown much as Bush did before the Iraq War. “That’s not Obama’s fault,” he said, “but it’s going to make him look weak because he’s the one sitting in the Oval Office.”