TIME IS RUNNING short for the United States and Iraq to agree on a role for U.S. troops after the end of this year. Neither most Iraqi leaders nor U.S. commanders believe that a full withdrawal should take place by Dec. 31, as laid out in the 2008 accord negotiated by the Bush administration. But the two governments are slow in coming to an agreement on what a follow-on U.S. presence would look like, even as the 47,000 American soldiers left in the country start to ship out. Worse, officials in Baghdad and Washington appear to be having trouble agreeing among themselves on what they want.

The problems with a full pullout are obvious: Iraq is not ready to defend its borders, including against the infiltration of weapons and militants from Iran. Al-Qaeda remains a menace, as it demonstrated in a spectacular series of attacks last month. And severe tensions remain along the fault line between Iraqi Kurdistan, an autonomous region, and the rest of the country. A stay-on U.S. force could help prevent the eruption of sectarian conflict, ensure that counterterrorism missions against al-Qaeda continue to be effective and — most important, from the point of view of U.S. strategic interests — ensure that Iraq is able to maintain its independence from Iran.

To its credit, the Obama administration let it be known months ago that it was prepared to deploy a follow-on force, in spite of the president’s pledges to remove all U.S. troops by the end of 2011. But U.S. officials said that the Iraqi government had to come forward with a request, placing the onus on the fragile coalition of Prime Minister Nouri al-Maliki. Mr. Maliki is dependent for support on the Shiite party of Moqtada al-Sadr, an Iranian client who has threatened that his militia will wage war against U.S. troops if they stay. The Maliki government nevertheless has opened negotiations with U.S. officials in Baghdad about what it describes as a training mission.

The administration, meanwhile, appears to be wrestling with its own internal rifts. U.S. commanders developed plans for follow-on forces ranging from 10,000 to as many as 18,000 troops. But senior Pentagon officials let it be known last week that a much lower number, in the range of 3,000, had been imposed by the White House. A force that small would have trouble defending itself against Iranian-sponsored militants and al-Qaeda, much less carry out an effective training or counterterrorism missions. It would mean giving up any effort to prevent violence in Kurdistan.

When we asked the White House to explain its thinking, we were told there was no basis to the reports of a 3,000-troop option. We hope that is the case. Any continuing military mission in Iraq should be founded on clear goals and a calculation of the troops needed to accomplish them — not an estimate of what troop number will acceptable to Congress or the president’s base of supporters. If Iraqi leaders and U.S. commanders believe that American troops are needed to preserve the country’s stability and sovereignty — and they do — then President Obama should make a commitment to the force that is necessary.