President Obama speaks at American University's School of International Service on Wednesday. (Pete Marovich/Bloomberg News)

President Obama lashed out at critics of the Iran nuclear deal on Wednesday, saying many of those who backed the U.S. invasion of Iraq now want to reject the Iran accord and put the Middle East on the path toward another war.

Obama also said that if Congress rejects the deal, it will undermine America’s standing in global diplomacy, leaving the United States isolated and putting Israel in even greater peril.

While calling the nuclear accord with Iran “the strongest nonproliferation agreement ever negotiated,” Obama also seemed to turn the vote on the deal into a referendum on the U.S. invasion of Iraq a dozen years ago, a decision he portrayed as the product of a “mind-set characterized by a preference for military action over diplomacy.”

Obama said that when he first ran for president, he believed “that America didn’t just have to end that war. We had to end the mind-set that got us there in the first place.” He added that “now, more than ever, we need clear thinking in our foreign policy.”

It was the president’s sharpest attack yet on opponents of the Iran nuclear deal, which he sees as a defining achievement amid an often rocky foreign policy record.

President Obama hammered critics of the nuclear deal negotiated with Iran, saying Republicans in the Congress who oppose it are making “common cause” with Iranian hard-liners. (AP)

In a two-hour White House meeting Tuesday night with Jewish American groups, Obama seemed particularly bothered by a multimillion-dollar ad campaign aimed at stopping the deal. On Wednesday afternoon, the president used his Twitter account to say: “There’s no such thing as a ‘better deal.’ Walking away risks war.”

As he nears the end of his tenure, Obama has been arguing forcefully that diplomacy can yield benefits, even as his administration continues to use targeted strikes by drones and struggles to deal with civil war in Syria, the rise of the Islamic State and confrontation with Russia over Ukraine.

“I have not shied away from using force when necessary,” Obama said, noting he had authorized military actions in seven countries. “. . . I’ve had to make a lot of tough calls as president, but whether or not this deal is good for American security is not one of those calls. It’s not even close.”

Obama spoke from American University, the same venue used by President John F. Kennedy to promote efforts to reach a landmark nuclear test-ban treaty with Moscow at the height of the Cold War. Obama invoked that 1963 speech, saying Kennedy “rejected the prevailing attitude among some foreign policy circles that equated security with a perpetual war footing.”

Instead, Obama said, Kennedy sought “a practical and attainable peace, a peace based not on a sudden revolution in human nature but on a gradual evolution in human institutions, on a series of concrete actions and effective agreements.”

But many observers felt that Obama’s speech was more caustic and partisan than Kennedy’s. “Walk away from this agreement and you will get a better deal — for Iran,” he said to critics.

Here are key moments from President Obama's speech at American University on Aug. 5, addressing the international deal on Iran's nuclear program that Congress is considering. (AP)

At one point, Obama brushed aside comments by Iranian hard-liners who he said do not reflect what all Iranians believe and are the “most comfortable with the status quo.” The president added: “It’s those hard-liners chanting ‘Death to America’ who have been most opposed to the deal. They’re making common cause with the Republican caucus.”

Later, Senate Majority Leader Mitch McConnell (R-Ky.) called on Obama “to retract his bizarre and preposterous comments” and said that Democrats who have already stated their opposition would be “insulted” by them.

Obama did not shy away from engaging foes of the Iran deal and linking them to the decision to invade Iraq.

“The single greatest beneficiary in the region of that war was the Islamic Republic of Iran, which saw its strategic position strengthened by the removal of its long-standing enemy, Saddam Hussein,” Obama added. He also noted that when President George W. Bush took office, Iran did not possess any centrifuges, the machines needed to produce nuclear bomb material, while when Obama took office Iran already had installed several thousand.

Even some supporters of the nuclear deal were put off by Obama’s argument. Many critics of the agreement were proponents of war in Iraq, but that does not make them warmongers, said Robert Einhorn, an arms-control and nonproliferation analyst with the Brookings Institution.

“I think it will offend more than convert,” said Aaron David Miller, a vice president at the Wilson Center and a former Middle East negotiator at the State Department. Miller supports the agreement but said Obama’s speech “paints those who are not reckless critics of this agreement with a large brush.”

Others who have met directly with Obama said they were impressed by the resolve with which he is making his case. They argue that the president has no choice but to fight against fierce criticism from Republican rivals and some Jewish groups opposed to the deal.

Obama has been irked by ad campaigns against the deal, including one comparing him to Neville Chamberlain, the British prime minister leading up to World War II, who has been widely blamed with not standing up to Adolf Hitler.

Alexandra Stanton, a board member at J Street, a group that supports the deal, said Obama “has a right to combat what he thinks are campaigns against him laden with non-facts and offensive statements. He has a right to call that out, a right to say he’s concerned about it and that he finds it objectionable.”

Obama appears to have made inroads with some Senate Democrats. On Wednesday, Sens. Chris Murphy (Conn.) and Angus King (Maine), an independent who caucuses with the Democrats, announced their support. On Tuesday, Sens. Barbara Boxer (Calif.), Timothy M. Kaine (Va.) and Bill Nelson (Fla.) backed the plan.

But the president has been less successful in wooing opponents among influential Jewish American groups.

“He feels the arguments that have been deployed against the deal are inaccurate and it’s his job to set the record straight,” said Jason Isaacson, who is the director of government and international affairs at the American Jewish Committee and attended the meeting with Obama.

Although Isaacson called Obama “a forceful salesman,” the American Jewish Committee announced Wednesday that it would oppose the nuclear deal.

Republicans also criticized how Obama has framed the debate.

“Does anybody in America believe that if we turn down this deal, this president is going to engage in war with Iran?” asked Senate Foreign Relations Committee Chairman Bob Corker (R-Tenn.). “That’s one of those straw men that demeans the debate.”

The heart of Obama’s address sought to hammer home the administration’s views that the alternative to the deal is conflict.

“I say this not to be provocative,” Obama said. “I am stating a fact. . . . The choice we face is ultimately between diplomacy and some form of war, maybe not tomorrow, maybe not three months from now, but soon.”

Obama and other top administration officials, including Secretary of State John F. Kerry, have framed the Iran deal as a last chance to roll back Iran’s nuclear ambitions and, in particular, the scope of its ability to enrich uranium. In exchange, international sanctions on Iran would be eased.

Speaking directly to lawmakers opposing the deal, Obama said rejection would cost more than missing a chance to curb Iran’s nuclear program.

“We will have lost something more precious,” he said, “America’s credibility as a leader of diplomacy, America’s credibility as an anchor of the international system.”

Obama emphasized that every nation that has weighed in on the deal has backed it — except Israel, which fears for its own security and whose prime minister, Benjamin Netanyahu, has been among the most vocal critics.

“I do not doubt his sincerity, but I believe he is wrong,” Obama said.

The West and its allies fear that Iran’s nuclear fuel facilities could one day be expanded to make weapons-grade material. Iran insists it does not seek nuclear arms but demands that it retain the capacity to make its own fuel for peaceful reactors.

Under the deal reached last month, U.N. inspectors from the International Atomic Energy Agency would have “unprecedented” access to Iranian nuclear sites, Kerry has told lawmakers. But some critics have questioned provisions that require advance notice — and possible negotiations with Iran — to inspect other areas of possible nuclear-related activity. The procedure could delay inspectors by up to 24 days.

Obama retorted that once an area of suspicion is identified, it would be watched “continuously” until inspectors can get to it and that they would get in even if Iran objects.

Obama also addressed complaints that lifting economic pressures on Iran could end up funding Iran’s military and its proxies in the region, including Lebanon’s Hezbollah and Syrian President Bashar al-Assad.

“If we are serious about confronting Iran’s destabilizing activities, it is hard to imagine a worse approach than blocking this deal,” he said. “Instead, we need to check the behavior that we are concerned about directly, by helping our allies in the region strengthen their own capabilities.”

The Iran pact faces widespread opposition in Congress — even among some Democrats — before the Sept. 17 deadline to vote. If Congress votes for a bill rejecting the deal, Obama has promised to veto it, setting up the key showdown over whether opponents could muster enough votes to secure an override.

“Shut out the noise,” he urged lawmakers. “Consider the stakes.”

Brian Murphy, Carol Morello, Karoun Demirjian and Mike DeBonis contributed to this report.