Barack Obama is president of the United States today, in large measure, because he said this in 2002: "What I am opposed to is a dumb war. What I am opposed to is a rash war... a war based not on reason but on passion, not on principle but on politics."

Obama was, of course, speaking about his opposition to war with Iraq. His comments were tragically prescient, but also politically helpful in ways that he could hardly have imagined at the time. More than five years later, this statement of opposition – in contrast to his Democratic rival Senator Hillary Clinton's yes vote in support of the war – would become the defining difference between the two candidates.

Today, however, these words are a shadow over Obama's presidency as he faces the difficult decision about whether to re-engage militarily in that tortured nation – and blunt the offensive of Isis, the radical Sunni jihadist group that has taken over Mosul, Iraq's third largest city. Not only can they further destabilise the Iraqi government, but they can also drag the region into war with Shias on one side and Sunnis on the other.

For the US, the threat is less acute, but not absent. The potential for Isis to set up a safe haven for fellow jihadists has an eerily similar feel to the situation in Afghanistan pre-9/11. Indeed, the argument to use US drones against Isis might be stronger than the one being used to justify current US drone policy in Pakistan and Yemen.

The problem for Obama is that his history with Iraq makes responding to this very real challenge incredibly difficult. Back in 2002, when Obama came out against the Iraq war, it was a move that hardly seemed like a stroke of political brilliance. At the time, there were few Democrats willing to take the same stand and even fewer who were mulling a presidential run. A year after 9/11 and, with all the historical vulnerabilities that dovish Democrats have long faced on national security, support for war, even begrudgingly, seemed like the smarter political play. Taking the opposite approach became Obama's ticket to political fortune.

As a candidate, he repeatedly promised to end the war. It was a job made that much easier by his predecessor, George W Bush, who signed a status of forces agreement with the Iraqi government in 2008 that pledged the withdrawal of all US troops by end of 2011.

Nonetheless, Obama consistently trumpeted the role he played in bringing the conflict to a conclusion. And while he could not avoid his own, albeit smaller, dumb war in Afghanistan, the conflict in Iraq was a regular reminder of the need for America to avoid the same sort of military entanglements – a Vietnam syndrome for a new generation. Obama's foreign policy presidency has, in many respects, been an exercise in exorcising the demons of Iraq – and the mindset that made the war possible – from the American psyche.

Indeed, only two weeks ago at the US Military Academy at West Point, Obama reminded the graduating cadets that "some of our most costly mistakes came not from our restraint, but from our willingness to rush into military adventures without thinking through the consequences… tough talk often draws headlines, but war rarely conforms to slogans".

These words, however, are not just a reflection of Obama's thoughts about war and peace; they reflect the views of the nation he leads, which is exhausted and weary from 12 years of almost constant war. Americans want no part of another fight and especially not in Iraq.

So even if Obama wanted to act – and it's difficult to imagine that he has any desire to go back on perhaps the most significant foreign policy accomplishment of his presidency – it would be unlikely to win strong popular support. Ironically, it could undermine the modest yet hardly restrained Obama vision for US global leadership.

This is Iraq's most useful and oddly counterproductive legacy. It has so poisoned the well for US military action that even when the use of force can be justified, the political constraints are, well, simply too constraining. Moving forward – aided and abetted by Obama's own failures in Afghanistan and Libya – it will be that much more difficult to fight dumb, rash wars. But make no mistake; it's going to be hard to fight smart ones, too.