It may seem a little premature for the White House to take a victory lap on the landmark nuclear deal agreed to between Iran and six world powers in July. But on Wednesday, President Obama secured enough votes, all from Democrats, to uphold his veto when Republicans in Congress try to pass a binding resolution of disapproval this month.

It's now clear that critics of the deal won't win that vote, which would prevent Obama from lifting sanctions against Iran in exchange for limits on its nuclear program, as agreed to in the accord. Republicans are already coming up with other ways to thwart the deal, but this is a big defeat for their efforts. At the beginning of August, it looked like the Iran deal's opponents had the upper hand.

But after enduring several politically brutal summers in years past, Obama won this one.

And he did it by beating back a rare congressional speech by Israeli Prime Minister Benjamin Netanyahu, vocal and united opposition from Republicans, and a $20 million campaign to sink the deal from a group called Citizens for a Nuclear Free Iran, an offshoot of the powerful American Israel Public Affairs Committee (AIPAC). Another group, the American Security Initiative, spent $10 million trying to whip up opposition. In comparison, J Street, the liberal Jewish group leading outside efforts to support the deal, spent about $5 million.

So, how did Obama pull this off? First, he didn't do it alone.

Opponents of the deal were counting on the August recess to gin up opposition to the deal, expecting on-the-fence lawmakers to be tipped into the anti-accord column by negative TV ads and outrage among constituents back home. "Conventional wisdom seemed to be as this dragged through August the benefit would accrue to opponents of the deal," Sen. Chris Murphy (D-Conn.) told Politico. "That has simply not been the case."

That's partly because the public outrage never really materialized. But it was also because Democrats learned from past mistakes.

The summer-break debacles with ObamaCare, the Tea Party, and various budget showdowns were "useful because I could say to people that we have to be proactive because I know the other side will be," House Minority Leader Nancy Pelosi (D-Calif.) tells The New York Times. "There was a plan, and there continues to be a plan."

Pelosi and a group of fellow House Democrats — Reps. Jan Schakowsky (Ill.), Lloyd Doggett (Texas), David Price (N.C.), and Rosa DeLauro (Conn.) — set up a war room in the Capitol, organizing a methodical rollout of endorsements by lawmakers and making sure statements of support from experts and military leaders reached the press and wavering lawmakers.

The White House had a war room, too, and a secret weapon: Energy Secretary Ernest Moniz. Moniz, a nuclear physicist, made several presentations to lawmakers over the summer. "Not only did he know the science," explain Carl Hulse and David M. Herszenhorn at The New York Times, "he could explain it clearly, persuasively, and without the condescension some heard in Secretary of State John Kerry's presentations."

Several Democrats have said they were also persuaded to back the deal after senior diplomats from the other five world powers — Britain, France, Germany, Russia, and China — spoke with a dozen or so lawmakers right before the August break, assuring them that nobody else was going to return to the negotiating table if this deal fell through. That sank the argument from opponents that a better deal was possible.

"They basically said unanimously this is as good a deal as you could get and we are moving ahead with it," said Sen. Chris Coons (D-Del.), one of the most recent backers of the deal. "They were clear and strong that we will not join you in re-imposing sanctions."

The final key players in the White House's imminent victory have been the deal's opponents. They never articulated a credible alternative to the Iran deal, arguably focused on the wrong issues, and allowed the debate to become a partisan fight. Netanyahu's speech helped define the issue as a question of politics, not national security.

Perhaps most helpfully for supporters of the Iran nuclear deal, its "most credible opponents have been relatively low-key in taking on the White House during the past few weeks, while [Donald] Trump, [Sen. Ted] Cruz, and other GOP presidential candidates have used increasingly incendiary language to denounce the agreement," say Politico's Burgess Everett and John Bresnahan. "That's only helped the White House, which has gone to great lengths to mollify nervous Democrats."

The White House has gone to great lengths, period. It's always a fight to overcome a presidential veto, especially on foreign policy, and the Obama team is still pushing for enough votes to prevent the disapproval resolution from even getting that far. But Obama had some powerful advocates trying to cripple one of his biggest foreign policy accomplishments. If they fail, as seems likely, it will be at least partly due to the White House finally learning to protect itself from the burning political heat of August.