The formal end of the U.S. war in Iraq on December 15 enhances neighboring Iran as a major, unpredictable factor in the U.S. presidential election of 2012.

First, a look back: Iran’s mullahs already had one opportunity to affect American politics, in 1980. Their seizure of the U.S. embassy in Tehran for 444 days haunted Pres. Jimmy Carter’s reelection campaign and — thanks to such developments as yellow ribbons, a “Rose Garden” strategy, a failed rescue operation, and ABC’s America Held Hostage program — contributed to his defeat. Ayatollah Khomeini rebuffed Carter’s hopes for an “October surprise” release of the hostages and twisted the knife one final time by freeing them exactly as Ronald Reagan took the presidential oath.

Today, Iran has two potential roles in Obama’s reelection campaign: as disrupter in Iraq, or as the target of U.S. attacks. Let’s look at each of them:

Who lost Iraq? Although George W. Bush’s administration signed the status-of-forces agreement with the Iraqi government, stipulating that “all the United States Forces shall withdraw from all Iraqi territory no later than December 31, 2011,” Obama’s decision against keeping a residual force in Iraq made the troop withdrawal his choice and his burden. This puts him at risk: Should things go badly in Iraq in 2012, he, not Bush, will take the blame. In other words, Iran’s supreme guide, Ali Khamenei, can make Obama’s life miserable.

Khamenei has many options. He can exert more control over those many Iraqi leaders who are Shiite Islamists with a pro-Iranian outlook, some of whom even lived in exile in Iran — the prime minister, Nouri al-Maliki, for example. The Iranians can also influence Iraqi politics via the country’s intelligence services, which they have already substantially penetrated. Or they can move Iranian troops at will into Iraq, as tens of thousands of U.S. troops are now gone from Iraq’s eastern border, and engage in mischief of their choosing. Finally, they can support proxies such as Moqtada al-Sadr or dispatch terrorist agents.

In 1980, the Iranians manipulated the American political process with hostages. In 2012, Iraq is their plaything. Should Iran’s rulers decide to make trouble before November 6, the Republican candidate will blame Obama for “losing Iraq.” Given Obama’s long opposition to the war, that will sting.

(Alternatively, the Iranians can shift gears and make good on their threat to close the Straits of Hormuz to imperil the 17 percent of world oil that goes through that waterway, thereby creating global economic instability.)