WASHINGTON -- The killing of two American servicemen and the eruption of deadly anti-American protests in Afghanistan confronts President Obama with a potential political weakness in a foreign policy that has so far offered few easy targets to Republican candidates eager for an opening.
But the White House and the Obama campaign believe that, if anything, the bloodshed in Afghanistan will reinforce the sentiments of a large majority of Americans who want to get the troops out of there as soon as possible. This, the president's aides said, will constrain Mitt Romney or other Republicans seeking to benefit from a perception that Mr. Obama's Afghan strategy has gone awry.
Still, the sudden flare-up in Afghanistan is a vivid reminder -- like rising gasoline prices or tensions over Iran's nuclear program -- that Mr. Obama's path to re-election is likely to be strewn with issues that have a momentum of their own, even as Democrats watch the bitter Republican presidential primary take a toll on the opposition.
"The lessons you take from all of this is that there are lots of things beyond our control," a senior administration official said last week. "They keep all of us up at night all the time. We just got to do the things we can control."
Mr. Romney did try to seize on the violence, which followed the burning of copies of the Koran by American personnel and prompted the United States to pull its advisers out of Afghan ministries. He called it an "extraordinary admission of failure" in Mr. Obama's plan to wind down the war by 2014.
Speaking on "Fox News Sunday," Mr. Romney repeated his charge that the president never should have announced a specific withdrawal date for troops because he said it emboldened the Taliban to "wait us out." He added that Mr. Obama's apology for the Koran burnings, in a letter to President Hamid Karzai, "sticks in the throats" of Americans after the sacrifices soldiers made to help the Afghan people.
On Monday, the White House defended the president's apology, which it said encouraged Mr. Karzai to call for calm. The administration noted that former President George W. Bush apologized to Iraq in 2008 after a soldier used a copy of the Koran for target practice. And it said the attacks would not alter its timetable in Afghanistan, even though Mr. Obama recognizes that public support for the war is fraying.
"He does not want American troops to be in Afghanistan any longer, not a day longer than they need to be to complete this mission," said the press secretary, Jay Carney. "It's a clear policy with very clear goals. And it is a policy that is very clear-eyed about what our objectives are, and what can be achieved in Afghanistan."
At the Pentagon, the press secretary, George Little, said Defense Secretary Leon E. Panetta and Gen. Martin E. Dempsey, the chairman of the Joint Chiefs of Staff, were "fully committed to our strategy in Afghanistan."
"We know that the spirit of American, coalition and Afghan forces will be tested throughout the campaign in Afghanistan," he said. "Anyone who believes they can weaken our resolve through these cowardly attacks is severely mistaken." Officials in Kabul said the mood, while tense, was calmer on Monday.
To the extent there is clarity, however, some analysts say the anti-American outbursts merely crystallize how much the administration has abandoned its original goal of transforming Afghanistan into a secure, functioning society. By the middle of last year, experts said, the United States and its NATO allies had given up their plan for a "conditions-based" withdrawal in favor of a rush for the exits.
"It is now clear that withdrawal timetables will continue to accelerate, cutbacks will continue to grow and popular attention will continue to shift away from Afghanistan," Anthony H. Cordesman, a longtime military analyst at the Center for Strategic and International Studies, said in a statement.
The country that the United States will leave behind, Mr. Cordesman said, will continue to be plagued by official corruption, barely competent military and police forces and a stubborn Taliban insurgency. It will be less a transition to Afghan control, he said, than a "muddle through."
Mr. Carney argued that the president's goal was always narrower: to defeat Al Qaeda and prevent terrorists from using Afghanistan as a haven. It was not, he said, to build a "Jeffersonian democracy" in the country.
Such debates may have little echo on the campaign trail, where voters from both parties seem eager for a brisk end to the war. Last June, 79 percent of Americans said they approved of Mr. Obama's plan to reduce the number of troops in Afghanistan -- beginning in 2011, with a pullout of 33,000 by the end of this summer -- according to a New York Times/CBS News poll. Just 17 percent said they disapproved.
On Monday, Newt Gingrich said at a Republican luncheon in Nashville that Afghanistan's problems could not be fixed. "There are some problems where you have to say, 'You know, you are going to have to figure out how to live your own miserable life,' " he said, according to The Atlanta Journal-Constitution.
While Democratic analysts said that a major foreign upheaval -- an Israeli bombing raid on Iran, for example -- could scramble the election, attacks on American troops in Afghanistan were likely simply to harden the public's conviction that the United States should stick to, or even accelerate, its withdrawal timetable.
"The most recent attacks on American personnel will deepen the public's support for bringing our troops home sooner rather than later," said Geoff Garin, a pollster for Democratic candidates and one of the independent "super PACs" backing Mr. Obama. "So, on the politically operative question of what should happen next, events are reinforcing President Obama's position rather than weakening it."
The Obama campaign also argues that Mr. Romney has not offered a credible alternative to the administration's plan. "Governor Romney needs to explain why he would leave American troops in Afghanistan indefinitely, even as we are decimating Al Qaeda and the Afghans are preparing to step up and take control of their security," said a spokesman for the campaign, Ben LaBolt.
For Mr. Romney, who has said he would defer to the counsel of his military commanders about when to withdraw troops, the violence in Afghanistan is emblematic of a foreign policy based on "retreat, appeasement and weakness," said a spokeswoman for the Romney campaign, Andrea Saul.
"As he is in many other parts of the world," Ms. Saul added, "Barack Obama is leaving our position in Afghanistan worse off than when he entered office."
Thom Shanker contributed reporting.
This article originally appeared in The New York Times .