(Shah Marai/AFP/Getty Images)

WHEN PRESIDENTWhen President Obama announced in 2011 the withdrawal of all U.S. troops from Iraq, he was sanguine about that nation’s future. U.S. soldiers could be “proud of their success,” he said, and he was “confident” that Iraqis would now “build a future worthy of their history as a cradle of civilization.”

Today’s reality of civil war, humanitarian horror and political fracturing is at odds with Mr. Obama’s sunny predictions. So it is almost breathtaking that he remains committed to the same strategy, founded on the same debunked theory of human behavior, in Afghanistan.

The strategy is to pull out all U.S. troops. The theory, unlikely on its face and resoundingly disproven in Iraq, is that leaders will be more likely to make political compromises if they feel threatened and abandoned than if they feel secure.

Neither in Iraq nor Afghanistan did the debate concern prolonging the U.S. combat mission. The question rather was whether to station a modest number of troops — 10,000 to 15,000 was the range mentioned by generals — once that mission ended. Their job would be to train and support local forces and, crucially, to maintain some U.S. influence in order to continue nudging democracies in their political infancy toward compromise, human rights and civilian control of the military.

Mid-level White House officials tried to push for such things in Baghdad even after the troop withdrawal. But they found themselves with little sway, as Prime Minister Nouri al-Maliki, without U.S. reassurance, unsurprisingly fell back on supporters in Iran and within Shiite militias. Progress that had been made in cooperation among Shiites, Sunnis and Kurds was reversed; U.S.-trained professionals were booted from the defense and interior ministries in favor of sectarian loyalists.

“People have said, ‘Doesn’t this show that you should never take the troops out of Afghanistan?’ ” a White House official said this week, according to the New York Times. Mr. Obama’s response, according to this official: “He said, ‘No, it actually points to the imperative of having political accommodation. There’s a limit to what we can achieve absent a political process.’ ”

That’s true, of course. But what is the best way to promote political accommodation? Since Mr. Obama announced that he would pull all troops out of Afghanistan by the end of his second term, it’s not surprising that that nation’sAfghan factions have begun looking for ways to hedge their bets and ensure their survival if order begins to break down. Two presidential candidates have each laid claim to the office, and Secretary of State John F. Kerry’s effort to broker a compromise is in danger. As theThe Post’s Pamela Constable reported Wednesday, “fears are growing that Afghanistan’s fragile transition process could collapse into violence.”

What’s the best way to avoid such a collapse? Is it to offer support and assistance to those who take a chance at compromise? Or is it to wag a fingers, lecture and walk away? Iraq over the past three years provided an answer. But Mr. Obama seems determined to run the experiment again.