Secretary of Defense Bob Gates was in Iraq early this month urging Iraqi leaders to decide whether they want U.S. forces to stay beyond Dec. 31. "If there is to be a presence, to help with some of the areas where [the Iraqis] still need help," he said, "we're open to that possibility. But they have to ask."

This is a small, belated, but welcome step in the right direction. Until now the Obama administration has taken a hands-off attitude in Iraq, giving every indication that it would be fine with a complete pullout of the 50,000 U.S. troops currently in the country. This would presumably allow the president to make good on his 2008 campaign pledge to "end the war"-although U.S. troops aren't engaged in much of a war at the moment.

They are primarily involved in training, assisting and advising Iraqi forces, conducting counterterrorism missions, and serving as a buffer force to reassure all sides in Iraq's fractious politics that their opponents will not resort to force to achieve their ends. The reassurance provided by U.S. forces is important, given that violence continues to be perpetrated by Sunni and Shiite extremist groups, including al Qaeda in Iraq, whose premature obituary has been written more than once.

U.S. forces play a particularly important role as a peacekeeper between the Kurdish peshmerga militia and the Iraqi Security Forces along the ill-defined frontier (the "Green Line") between Iraq proper and the Kurdish Regional Government. On a visit to Iraq last month, I encountered the umpteenth crisis between the Kurds and Arabs. The peshmerga had come down south of the Green Line to surround the disputed city of Kirkuk. The Iraqi army was moving troops to the area. Shooting could have broken out were it not for the presence of the U.S. army in the middle.

Peshmerga leaders won't talk directly to their Iraqi counterparts-they need a trusted third party in the room. What will happen next year if another such crisis erupts when U.S. troops are gone?

The U.S. Embassy has an ambitious plan to deploy some 1,000 diplomats backed by 16,000 contractors to maintain a presence there and at several consulates around the country. But even if they pull this off-a feat of logistics that would be unprecedented for the State Department-there will be no replacement for the peacekeeping function that is performed by our troops.

Contractors may be successful in training Iraqi forces but I have my doubts about whether they will be up to the magnitude of the task. Iraq has no fighter aircraft and no air-control system. It has only some 70 tanks and no artillery. Its army has almost no experience in combined-arms warfare, having devoted the last eight years, for understandable reasons, to counterinsurgency operations.

In other words, Iraq is almost defenseless. That makes it easy prey for Iran, its historic rival. This doesn't mean that an Iranian invasion is likely. Yet Iranian bullying and influence-peddling is going on all the time, and if Iraq can't defend its borders, Tehran will have an extra element of coercive leverage.

Under these circumstances, leaving Iraq entirely would be an act of folly. We are still in Kosovo, South Korea and other post-conflict zones that are far more stable. We need to be in Iraq too.

We don't need to keep 50,000 troops there, but a continuing presence of 20,000 military personnel, as argued by military analysts Frederick and Kimberly Kagan, would seem to be the minimum necessary to ensure Iraq's continued progress. It would also make possible an Iraqi-American alliance that could become one of the linchpins of security in this strategically vital region. Having active bases in Iraq would allow us to project power and influence, counter the threat from both Iran and al Qaeda, and possibly even nudge the entire Middle East in a more pro-Western direction.

Before I arrived in Iraq, I had thought there might be behind-the-scenes negotiations going on to extend the Status of Forces Agreement to allow some troops to remain behind. But after spending several days talking with Iraqi and American officials, civilian and military, I came to the conclusion that no talks had started because each side was waiting for the other to go first. Mr. Gates has finally broken through the "After you, Alphonse" syndrome, but his intervention may be too little, too late.