President Obama pauses while speaking at American University on Aug. 5. (Pete Marovich/Bloomberg)

Last week President Obama defended the Iran agreement in part by dismissing its critics as people who supported the war in Iraq 13 years ago — “the same people who seem to have no compunction with being repeatedly wrong,” he said.

Politicians and pundits should be judged on their records. If you think my support of the Iraq war in 2002 invalidates any other argument I will ever make, then you shouldn’t read my column. That’s fair enough.

It doesn’t seem to be Obama’s standard, though, when he’s feeling less embattled. If it were, he would not have chosen Joe Biden as his vice president and valued his foreign-policy advice over the past seven years; nor would he have appointed Hillary Clinton as his secretary of state in his first term or John Kerry in his second. For that matter, if it were Obama’s standard, he ought to be worried that so many supporters of the Iraq war, like Biden, Clinton and Kerry — like me, for that matter — support the Iran deal.

But if the Iraq war isn’t a single-issue litmus test for Obama, what are its lessons for foreign policy, including the Iran deal, and has the president drawn them correctly?

One obvious lesson is that intelligence on nuclear capabilities is notoriously unreliable. The Iraq war was fought on the basis of “one of the most public — and most damaging — intelligence failures in recent American history,” the Robb-Silberman commission concluded in 2005. On nuclear weapons, the intelligence community regularly has been caught by surprise, in Iran and Iraq but also in North Korea, Pakistan, India and the Soviet Union.

President Obama addressed the international deal on Iran's nuclear program at American University on Aug. 5. (AP)

Judging by his certitude on the United States’ ability to detect Iranian violations, it’s safe to say that’s not the Iraq war lesson Obama has taken to heart. “If Iran cheats, we can catch them, and we will,” he boasted last week.

No, the lesson Obama has in mind is that war is unpredictable and destructive and should always be a last resort. I agree with that, as, I think, would most critics of the Iran deal, notwithstanding the president’s suggestion that they share “a preference for military action over diplomacy.”

The difficulty is that it is easier in hindsight to label wars as being smart or dumb, of choice or of necessity, than when making policy decisions in the face of many unknowns. Nothing illustrates that better than Obama’s own record.

He waged his own war of choice in Libya, a seven-month air campaign that dislodged dictator Moammar Gaddafi in 2011. Obama then refused to commit U.S. resources to postwar stabilization, with the result that Libya is now fractured in a brutal civil war that has opened havens for Islamist radicals.

He withdrew all U.S. troops from Iraq when it had achieved unity and relative stability, and he denied assistance to moderate pro-democracy forces in Syria when that nation’s dictator turned ferociously on them. The foreseeable, and foreseen, result of both decisions was growing instability and extremism. A malignant terrorist-run state put down roots at the heart of the Middle East.

This has been not only a humanitarian calamity, something Obama’s foreign-policy team considered intolerable when depredation on a similar scale was taking place in Darfur during a different presidency, but also a strategic disaster, as judged by Obama’s own metrics. He has been forced to return thousands of troops to Iraq, to conduct thousands of bombing sorties over Iraq and Syria — in short, to favor military action over diplomacy, and from a position of no-good-option weakness.

So, yes, war should always be the last option, and not every diplomatic compromise is appeasement. But as Obama has found, war is not always avoidable, and the judicious use of force early in a crisis, or even the threat of force, can sometimes forestall worse bloodshed later.

What are the lessons for Iran? From the start, Obama has made clear that he would use military force, if necessary, to prevent Iran from obtaining nuclear weapons. But he also made clear his judgment that there was no good military option. An attack could at best delay Iranian nuclearization; it could generate dangerous blowback, and it could leave the United States unsure what capabilities remained hidden inside Iran.

That judgment, understood as clearly by the Iranians as anyone, helps explain why the deal Obama negotiated fell so far short of his initial goals in the enrichment capability it allows Iran, the failure to account for past behavior, the inspections that Iran can delay and more. It explains, too, why some of us agree that even this imperfect deal is better than any alternative now available. But I do not assume that those who disagree are lusting for another war.

Read more from Fred Hiatt’s archive, follow him on Twitter or subscribe to his updates on Facebook.