What President Obama on Wednesday called the “outrageous and shocking” attack that killed the U.S. ambassador to Libya left his administration with a diplomatic crisis that threatened to undermine its long-term strategy in the Arab world.

The assault Tuesday evening on the U.S. Consulate in Benghazi and an earlier attack on the U.S. Embassy in Cairo represent the most serious challenge yet to Obama’s attempt to transform a traditionally anti-American region into one that is more trusting of U.S. intentions and can serve as a counterweight, with Israel, to Iran’s ambitions.

Although U.S. officials said they were still trying to determine who had carried out the assaults, signs pointed to radical Islamists as the likely perpetrators. The attacks offered a vivid reminder that despite more than a year of turbulence that has produced a more democratic Middle East and North Africa, violent extremists remain a potent force. And it is still unclear whether the new governments in Libya and Egypt are able, or willing, to confront those bent on attacking U.S. interests.

In Cairo, hundreds of demonstrators, some throwing stones, gathered near the U.S. Embassy late Wednesday and security forces fired tear gas to disperse them.

In a statement delivered in the White House Rose Garden, Obama said the deaths of Ambassador J. Christopher Stevens and three other U.S. officials in Benghazi would be investigated and the perpetrators brought to justice.

Whatever the outcome, Obama said, the United States “will not waver” in working with the Arab people and their new governments. He emphasized the continuation of an outreach policy that began even before the uprisings that last year drove longtime U.S. allies in Tunisia, Egypt and Yemen from power, overthrew Libyan dictator Moammar Gaddafi, spurred protests against entrenched autocrats throughout the region and sparked an ongoing civil war in Syria.

In his June 2009 “new beginning” speech in Cairo, Obama pledged to treat Muslims with respect and to recalibrate the U.S. role in the region. He promised to be a more honest broker in the Arab conflict with Israel than he believed his predecessor had been.

But since the heady days of spring 2011, when the U.S.-backed resignation of Egyptian President Hosni Mubarak was followed by the U.S. killing of al-Qaeda leader Osama bin Laden, the course of reform in the Arab world has been uneven.

In remarks Wednesday, Secretary of State Hillary Rodham Clinton emphasized that only a “small, savage group” was responsible for the Benghazi attack, not the Libyan government or people. But as al-Qaeda and its allies have repeatedly shown, even small groups can wield major influence.

If nothing else, the new crisis appeared likely to cement Obama’s determination not to intervene militarily in Syria. “It will certainly give pause, or should give pause, to people who are pressing for a kind of involvement that you’ve got to back up” with significant force “to be successful,” Sen. John F. Kerry (D-Mass.) , chairman of the Foreign Relations Committee, said in a telephone interview.

Obama’s Republican rival for the presidency, Mitt Romney, wasted no time in condemning the president and his policies as fostering a sense of American weakness and lack of leadership, turning the Libya and Egypt attacks into a prominent issue in an election campaign that has included foreign policy only on the margins.

Kerry and others backing the overall policy insisted that it is the right one. “There will be moments of danger and moments of setback and confrontation. But we have to continue to press our interests, and you can’t retreat,” the senator said. The United States, he said, is “working very effectively with Turkey, Jordan, Qatar, the Saudis, the [Persian] Gulf states.”

As for Libya, “we are as committed today as we have ever been to a free and stable Libya. That is still in America’s interest,” a senior administration official said.

Although the U.S. Embassy in Tripoli is being evacuated under emergency status, there was no discussion Wednesday of cutting back American aid to Libya or anywhere else — including Egypt, where a high-level U.S. trade delegation paid a visit this past weekend.

But Obama’s policies in the Arab world are almost certain to come under renewed scrutiny. His efforts to change the U.S. image in the region have yielded little positive movement in opinion polls there.

In an interview Wednesday evening with the Spanish-language cable channel Telemundo, Obama said he does not consider Egypt an ally, nor an enemy. The characterization raises questions about military and development aid to Egypt if Obama wins in November, as well as the leverage he will have in continuing to pressure Egypt to preserve its peace agreement with Israel — one of only two Arab nations with such an agreement.

In part, Obama’s lack of progress in changing the U.S. image in the region stems from his inability to make headway on resolving the Israeli-Palestinian conflict, despite promises to make it a priority.

Early on in his term, Obama’s rhetoric on the illegitimacy of Israeli settlement construction on land that Palestinians view as their future state raised Arab hopes that a president who spent years of his childhood in a Muslim-majority country would be different from his predecessors.

That posture has failed to achieve results or assuage Arab ire on the Palestinian issue, while also making Israel uncomfortable and angering its powerful supporters in the United States. Most recently, Israeli Prime Minister Benjamin Netanyahu sharply criticized Obama for what he sees as the president’s failure to stand up more firmly to Iran’s uranium enrichment program.

Dennis Ross, a former senior Middle East adviser to Obama who is now at the Washington Institute for Near East Policy, said the attacks in Egypt, one of only two Arab nations to have signed a peace treaty with Israel, should remind Obama and Netanyahu of their nations’ close relationship. “No country is affected more by this than Israel, and there is no difference between Netanyahu and Obama over their strategic goals, only over tactics,” Ross said.

With Israel pondering an attack on Iran, Obama already faced tough choices in how he manages the U.S. relationship with its closest Middle Eastern ally in the two months before Election Day. Tuesday’s attacks will also bring into sharp relief his handling of the relationship with Egypt and Libya.

A senior administration official, speaking on the condition of anonymity to voice a personal opinion, said consideration should probably be given to reducing the large number of American civilians who are deployed in dangerous places abroad in support of the Obama administration’s outreach efforts.

“We’ve got to stay out there, but we probably have way too many people,” the official said.

U.S. officials said the Defense Department has deployed a Europe-based Marine anti-terrorism unit to Libya to secure the embassy in Tripoli and assist in the evacuation of personnel and casualties from Benghazi. They declined to discuss any further deployments made or under consideration.

The embassy has been reduced to “emergency staffing levels,” one official said, without specifying the number. The evacuated staff members, including the three wounded, and the bodies of the four dead were being moved Wednesday to Ramstein-Landstuhl, a U.S. air base in Germany, where the wounded would be treated and the dead would be transferred home.