BAGHDAD — President Obama’s announcement on Friday that all American troops would leave Iraq by the end of the year was an occasion for celebration for many, but some top American military officials were dismayed by the announcement, seeing it as the president’s putting the best face on a breakdown in tortured negotiations with the Iraqis.

And for the negotiators who labored all year to avoid that outcome, it represented the triumph of politics over the reality of Iraq’s fragile security’s requiring some troops to stay, a fact everyone had assumed would prevail. But officials also held out hope that after the withdrawal, the two countries could restart negotiations more productively, as two sovereign nations.

This year, American military officials had said they wanted a “residual” force of as many as tens of thousands of American troops to remain in Iraq past 2011 as an insurance policy against any violence. Those numbers were scaled back, but the expectation was that at least about 3,000 to 5,000 American troops would remain.

At the end of the Bush administration, when the Status of Forces Agreement, or SOFA, was negotiated, setting 2011 as the end of the United States’ military role, officials had said the deadline was set for political reasons, to put a symbolic end to the occupation and establish Iraq’s sovereignty. But there was an understanding, a senior official here said, that a sizable American force would stay in Iraq beyond that date.