The purported deal to keep some troops in Afghanistan is a potential win for the U.S., and especially for all those who fought and sacrificed themselves to defeat Al Qaeda and protect the new government from collapse. But it is a bitter victory, and not just because President Barack Obama agreed to write an abject acknowledgement of American “mistakes.” It also reminds us of the opportunity that was lost in Iraq.

Several years ago, U.S. could have concluded a similar agreement with the new government of Iraq. The one sticking point was the legal exposure of U.S. personnel to the Iraqi legal system. That could have been ironed out, had President Obama wanted to do so. Despite his anti-war posture on the 2007-8 campaign trail, he had promised to leave a significant force in Iraq, large enough to protect the new government.

Yet that is not what President Obama really wanted–and everyone knew it. He wanted to erase the Iraq War from history–not just because he believed it was a strategic mistake, but also because it had been a success. The fact that the surge worked was a living rebuke to him and to the entire Democratic leadership, which had declared the war lost and preferred a precipitous withdrawal that could have led to genocidal civil war.

The reason they opposed the war had more to do with with political expediency than principle. In recent months, President Obama undid all of his arguments against the Iraq War by pressing for a military strike in Syria without UN justification, without any direct threat by Syria to the U.S., and–initially–without congressional approval. Small wonder that Bill Clinton once called Obama’s anti-war posture a “fairy tale.”

Whatever the rights and wrongs of getting into Iraq in the first place, the withdrawal has been a profoundly negative move. It has allowed Iran to expand its influence in Iraq. It has lowered American leverage with the new government. It has destabilized the country, which is experiencing a new wave of terrorist attacks. And it has removed U.S. ground troops from Iran’s border–a potential source of pressure on the Iranian regime.

A new agreement with Iraq should not have been so hard. If the U.S. could deal with Hamid Karzai–who was insulted by the Obama administration before it even took office, and insulted the U.S. in return–then surely we could deal with the Iraqi leadership. Yet President Obama hardly tried. He has even been more eager to reach a deeply flawed deal with Iran. The Afghanistan deal is a win–but highlights what Obama has lost.