WASHINGTON (AP) - His eye fixed firmly on securing a second term, President Barack Obama had hoped that the rest of the world would wait until after the election if it had to grow restless and demand his attention.
    
The eruptions in the streets of the Arab world, inflamed by an anti-Muslim video made in the U.S., mean Obama can put it off no longer. The protests are testing the president's foreign policy skills and giving voters a pre-election view of how he handles a crisis.
    
The turmoil also offers an opportunity - a risky one - for Obama to appear presidential in the midst of the election campaign, to contrast himself with a challenger less experienced in foreign policy and to illustrate that being president is not just about being a steward of the economy.
    
Even with a rebellion in Syria and tensions over Iran's nuclear ambitions, no international image can be more searing and demand more public attention than that of a U.S. embassy under attack and American civilians in peril. This week's angry demonstrators, flag burnings and imperiled civilians already were drawing comparisons to 1979, when Iranian revolutionaries stormed the U.S. embassy in Tehran and took 60 hostages and held them for 444 days, helping erode President Jimmy Carter's public support.
    
For Obama, the timing of the violent demonstrations less than two months before the election creates further complications.
    
His rival, Mitt Romney, jumped on the administration for what he claimed was a feckless response to the breach of the U.S. embassy in Cairo. A favored and popular U.S. diplomat, the ambassador to Libya Chris Stevens, was killed along with three other Americans in an attack on the U.S. Consulate in Benghazi, Libya. And protesters in the capital of Yemen stormed the U.S. embassy compound there and burned the U.S. flag.
    
"I know that it's difficult sometimes seeing these disturbing images on television because our world is filled with serious challenges," Obama told supporters Thursday in Golden, Colo. "It is a tumultuous time that we're in. But we can and we will meet those challenges if we stay true to who we are, and if we would remind ourselves that we're different from other nations."
    
The protests and the attack in Libya present a juggling act for the president. He must show resolve both at home and abroad, pressing foreign governments to do their part in protecting U.S. personnel and property, condemning the protesters and at the same time denouncing a provocative, though amateurish video that finds refuge in the cherished U.S. right of free speech. At the same time, he has been forced to push back on Romney.
    
Obama accused his GOP rival of having "a tendency to shoot first and aim later." And while even some Republicans flinched at the timing of Romney's criticism, that could be forgotten if protests continue to threaten U.S. overseas posts.
    
Still, in an election dominated by the economy, other issues have grabbed headlines, only to quickly recede.
    
The mob actions in Egypt, Libya and Yemen nevertheless present a challenge for Obama because they draw more attention than other foreign policy conundrums. What's more, in these instances the perpetrators are not state-sponsored, presenting Obama with a diffuse target.
    
"The risk here for President Obama is that he appears weak because there is not an easy military solution," said John Ullyot, a Republican strategist and former Senate Armed Services Committee aide. "You're talking about unruly mobs and shadowy figures."
    
Obama forcefully condemned the attack in Libya and has decried the assaults on the embassies. Secretary of States Hillary Rodham Clinton forcefully denounced the film, which depicts Muhammad variously as a cartoonish lecher, fool and thug.
    
But it was just that type of condemnation from the U.S. Embassy in Cairo that prompted Romney to accuse the administration of issuing an "apology."
    
The uprisings also draw attention to unrelated and more intractable foreign policy troubles with Syria and Iran.
    
The protests in Egypt came on the same day that Israeli Prime Minister Benjamin Netanyahu complained that no ally had the right to demand that it not strike at Iran over its nuclear buildup. The White House was forced to tamp down reports from Jerusalem that Obama had rejected a Netanyahu request to meet on the sidelines of a United Nations General Assembly meeting later this month.
    
U.S. officials said the president's schedule would not allow for any such meetings, a contrast to last year when he packed his visit to the U.N. with individual sessions with foreign leaders.
    
Then Obama and Netanyahu spent an hour on the telephone, and the White House said they "reaffirmed that they are united in their determination to prevent Iran from obtaining a nuclear weapon, and agreed to continue their close consultations going forward."
    
While the problems in Syria and tensions with Iran remain separate, U.S. officials are watching closely to ensure that the protests don't extend into Iran and get manipulated to provoke even deeper problems.

(Copyright 2012 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.)