But given the changed timetable, just as Iraqi political leaders are struggling to form a new government, American military leaders will be distracted by the myriad tasks of supervising major troop movements. On top of that, the deeper the troop withdrawals go, the more potentially destabilizing they will be  because the first withdrawals will be made in areas that are considered more secure, or where Iraqi forces are deemed more reliable or evenhanded.

By June, American troops may be leaving areas that are far from quiet, and where new tensions may be brewing as a result of the elections. Once again, the United States would be rushing toward failure in Iraq, as it did so often under the Bush administration, trying to pass responsibility to Iraqi officials and institutions before they are ready for the task.

By late summer, the Obama administration could find itself in the uncomfortable position of reconsidering its vows to get out of combat in Iraq by August and to remove all troops by the end of next year. This will be politically difficult for the president, but he has shown admirable flexibility in his handling of Iraq. My impression is that the American people now wish they had never heard of Iraq, but understand just what a mess it is and are willing to give the president a surprising amount of leeway.

Extending the American military presence will be even more politically controversial in Iraq, and for that reason, it would be best to let Iraqi leaders make the first public move to re-open the status of forces agreement of 2008, which calls for American troops to be out of the country by the end of next year. But I think leaders in both countries may come to recognize that the best way to deter a return to civil war is to find a way to keep 30,000 to 50,000 United States service members in Iraq for many years to come.

These troops’ missions would be far narrower than during the surge era; their primary goal would be to train and advise Iraqi security forces and to carry out counterterrorism missions. (It is actually hard to get below 30,000 and still have an effective force; many troops are needed for logistics, maintenance, medical, intelligence, communications and headquarters jobs, and additional infantry units are then needed to protect the people performing those tasks.)

Such a relatively small, tailored force would not be big enough to wage a war, but it might be enough to deter a new one from breaking out. An Iraqi civil war would likely be a three- or four-sided affair, with the Shiites breaking into pro- and anti-Iranian factions. It could also easily metastasize into a regional war. Neighboring powers like Turkey and Iran are already involved in Iraqi affairs, and the Sunni Arab states would be unlikely to stand by and watch a Shiite-dominated regime in Baghdad slaughter the Sunni minority. A regional war in the middle of the world’s oil patch could shake the global economy to its foundations and make the current recession look mild.

In addition, a continued American military presence could help Iraq move forward politically. No one there particularly likes having the Americans around, but many groups seem to trust the Americans as honest brokers. And there would be a moral, humanitarian and political benefit: Having American soldiers accompany Iraqi units may improve the behavior of Iraqi forces, discouraging relapses to Saddam Hussein-era abuses, or the use of force for private ends and feuds. Advisers not only instruct Iraqi commanders, they also monitor them.

As a longtime critic of the American invasion of Iraq, I am not happy about advocating a continued military presence there. Yet, to echo the counterinsurgency expert David Kilcullen, just because you invade a country stupidly doesn’t mean you should leave it stupidly. The best argument against keeping troops in Iraq is the one some American military officers make, which is that a civil war is inevitable, and that by staying all we are doing is postponing it. That may be so, but I don’t think it is worth gambling to find out.