It bolsters Obama's call for a quick exit but also could undercut one of the Democrat's signature issues -- opposition to the war -- as he prepares for a high-stakes trip to the region. It leaves McCain caught between his objections to any timetable and the evolving wishes the Republican president he hopes to succeed.
Iraq has been replaced by the sputtering economy as issue No. 1 for U.S. voters, but the war remains a pivotal campaign issue even though violence there has declined.
Less than four months before the election, it's uncertain whether apparent steps toward the war's conclusion will dilute the political power of Iraq in the campaign.
McCain sought to keep it on the front-burner by unleashing a new TV ad highly critical of his Democratic rival.
The ad says Obama hasn't been to Iraq in years and voted against war funding to win the nomination but "now Obama is changing to help himself become president." McCain, it says, has always supported the Iraq strategy "that's working."
Of the accord, McCain said it vindicated his longstanding call for more troops but was careful to suggest it left the timing of withdrawal indefinite. Obama commended the Bush administration for dropping its opposition to discussing with Iraq the removal of U.S. combat troops and urged it to pressure the leaders of Iraqi factions to reach political accommodations.
Iraq long has been a major difference between the two.
Obama, with no military experience and a thin foreign policy resume, opposed the war from the start and won the Democratic nomination in part by rallying the anti-war wing of his party with a full-throated call for withdrawal. The Illinois senator promises "I will end this war" but also has said that U.S. troop safety and Iraq stability might force him to adjust his timetable, and that his upcoming Iraq trip may lead him to refine, but not basically alter, his position.
McCain, an ex-Navy pilot and Vietnam prisoner of war who has long specialized in national security issues, supported the decision to go to war. The Arizona senator spent years criticizing President Bush for not sending more troops and now emphasizes that Bush's decision to finally do so last year has helped reduce the violence. McCain long has rejected any timetable or date for withdrawal.
The line between the two could blur now that Bush and Iraqi Prime Minister Nouri al-Maliki have agreed to force reduction language in a broader security agreement to keep American troops in Iraq after a U.N. mandate expires on Dec. 31. Specifically, the accord would include "a general time horizon" for meeting goals like "the resumption of Iraqi security control in their cities and provinces and the further reduction of U.S. combat forces from Iraq."
The language conflicts with Bush's once-rigid opposition to deadlines and timetables; he has vetoed Democratic-pushed legislation setting dates for U.S. cutbacks. The United States has resisted Iraqi calls for a specific timeline to withdraw U.S. forces. Now the White House says "a general time horizon" would not be "an arbitrary date for withdrawal."
From the campaign trail, Obama and McCain have carefully watched deliberations over the accord -- and begun maneuvering politically.
When al-Maliki publicly said he supported a timetable, Obama argued that the stance was in line with his own position and out of step with long-term presence favored by McCain and Bush. Said Obama: "I hope that this administration as well as John McCain is listening to what Prime Minister al-Maliki has to say."
Indeed, the U.S.-Iraqi agreement reinforces Obama's argument that troops should start coming home, for it's hard to argue against some timeframe when both countries have endorsed such an approach. However, the accord also could end up diluting one of Obama's core issues. If there are signs that the war is ending, would that dampen the enthusiasm and urgency felt by voters initially drawn to his anti-war stance?
Underscoring his precarious position, McCain has been choosing his words carefully. He didn't rush to react to al-Maliki's recent call for a timetable. After meeting in Washington with Iraqi President Jalal Talabani last month, McCain said he was "confident that the two nations, as sovereign nations, will reach agreement in the best interest of the United States of America and the best interest of the government of Iraq." Left unsaid was whether a timeframe should be a part of any agreement.
And for all his objections to a timetable, McCain recently said he envisions victory with most U.S. troops coming home by January 2013. Endorsing the agreement between Bush and al-Maliki could open McCain to charges flip-flopping and leave both candidates essentially on the same page. On the other hand, sticking with his objection to any timetable would allow him to distance himself from an unpopular president, but also would give Democrats an opening to paint him as a war enthusiast.
Brookings Institution political scholar Thomas Mann argues the agreement helps Obama more than McCain. "The public will see that even the Iraqis want us out," Mann said. "This makes it much more difficult for McCain to argue that Obama is aiming for defeat and not victory."
Polls show Obama leading McCain on just about all but defense issues, like who would be a good commander in chief and who would handle Iraq better.
To boost his foreign policy standing, Obama was preparing to head to Iraq and Afghanistan.
Republicans suggested the trip could end up benefiting McCain. "Obama is going on a terrain that's not his sweet spot, and it is McCain's sweet spot," said John Feehery, a one-time aide to former House Speaker Dennis Hastert.
Democrats countered that Obama could benefit by being seen as presidential in foreign settings. Said Bill Carrick, a one-time adviser to former House Minority Leader Dick Gephardt: "I don't think there's much risk at all."