Sometimes you have to fight battles you cannot win because fighting – regardless of the outcome – advances a larger cause.

Israel’s fight against the nuclear deal the major powers, led by US President Barack Obama concluded with Iran was such a battle.

The battle’s futility became clear on July 20, just six days after it was concluded in Vienna.

On July 20, the US administration anchored the deal – which paves the way for Iran to become a nuclear power and enriches the terrorism-sponsoring ayatollahs to the tune of $150 billion – in a binding UN Security Council resolution. Once the resolution passed, the deal became unstoppable.

Most of the frozen funds that comprise the $150b.

would have been released regardless of congressional action. And the nonproliferation regime the US developed over the past 70 years was upended the moment the deal was concluded in Vienna.

The fight in Congress itself probably couldn’t have succeeded even if the administration hadn’t made an end run around the lawmakers at the Security Council.

After Sen. Bob Corker, the chairman of the Senate Foreign Relations Committee, passed the law obligating Obama to secure the support of a mere third of the members of either House to implement his nuclear deal, its implementation was a foregone conclusion. The US Constitution gives sole power to approve international treaties to the Senate and requires a minimum of two-thirds approval for passage. Corker turned the Constitution on its head when he went forward with his bill. Far from curbing Obama’s executive overreach, Corker gave Obama unprecedented power to enact his radical, reckless nuclear agenda.

So if the fight against the deal was doomed to fail, why did the Israeli government decide to fight it for all it was worth? And why is Prime Minister Benjamin Netanyahu still fighting it even though there is no longer any way to stop Obama from enabling Iran to sprint across the nuclear finish line? By fighting Obama’s nuclear deal, Israel seeks to advance two larger efforts. First, it uses the battle to expand its capacity to act without the US to prevent Iran from acquiring nuclear weapons. Second, it is shaping its relations with the US both for the duration of Obama’s presidency and for the day after he leaves office.

As far as Iran’s nuclear program is concerned, Obama’s deal has not impacted Israel’s options for preventing the mullahs from getting the bomb.

Even before the US betrayed Israel, its Arab allies and its own national security interests and closed a deal that will transform Iran into a nuclear power and a regional hegemon, there was no chance that the Americans would take action to prevent Iran from developing atomic warheads.

That prospect was taken off the table in November 2007. The National Intelligence Estimate on Iran’s nuclear program published that month falsely – and scandalously – asserted that Tehran abandoned its nuclear weapons program at the end of 2003.

The NIE was a bureaucratic coup. CIA analysts, notorious since the 1970s for their biased and politicized analyses, used the falsified NIE to block then-president George W. Bush from dealing with Iran. After losing the public’s support for the war in Iraq, and after failing to find Saddam’s WMD (which magically fell into the hands of Islamic State 11 years after the US invasion), Bush was powerless to oppose an official assessment of the intelligence community that claimed Iran was not a nuclear proliferator.

As for Obama, in early 2008, even before he secured the Democratic presidential nomination, he announced that he wanted to negotiate with then-Iranian president Mahmoud Ahmadinejad.

At no time since was there any evidence supporting the notion that Obama would lift a finger to prevent Iran from going nuclear.

In other words, for the past eight years it has been apparent to everyone willing to see that Israel has but option for preventing Iran from acquiring nuclear weapons.

By fighting so strenuously against Obama’s nuclear deal, Israel improved its ability to carry out a military strike against Iran’s nuclear installations in two ways.

First, it removed the most serious domestic obstacle to carrying out such a strike.

Last week’s publication of audio recordings of former defense minister Ehud Barak discussing of Iran’s nuclear program revealed that for the past several years, Israel’s military and intelligence brass have blocked operations against Iran’s nuclear installations three times. In 2010, 2011 and 2012 the IDF chief of General Staff and senior generals supported by hesitant cabinet members refused to carry out instructions they received from Netanyahu and Barak to prepare to carry out such a strike.

There is no doubt that one of the main reasons they opposed lawful instructions was their faith in Obama’s security pledges.

For their part, the Americans did their best to subvert the authority of Israel’s elected leadership.

Over the past seven years Washington has sent a steady stream of senior officials to “oversee joint Israeli-American efforts” regarding Iran. It is now obvious that this “unprecedented cooperation” was never aimed at strengthening Israel against Iran. Rather, its aim has been to erode the government’s power to make independent decisions regarding Iran’s nuclear installations.

Had Netanyahu kept his criticism of Obama’s decision to give Iran a free hand to develop nuclear weapons quiet, the generals might have shrugged their shoulders and expressed gratitude for the shiny new weapons Obama will throw at them to “compensate” for giving nukes to a regime sworn to annihilate the country.

By making his opposition public, Netanyahu alerted the nation to the dangers. The top commanders can no longer pretend that US security guarantees are credible. Now they will be forced to kick their psychological addiction to worthless American security guarantees, accept reality and act accordingly.

Better eight years late than never.

The Americans weren’t the only ones paying attention to Israel’s fight. Israel’s Arab neighbors also saw how Netanyahu and Ambassador to the US Ron Dermer left no stone unturned in their efforts to convince Democratic lawmakers to oppose it. And the regional implications are already becoming clear.

As the Saudis’ willingness to stand with Israel in public to oppose this deal has shown, our neighbors have been deeply impressed by the diplomatic courage Israel has shown. If and when Israel strikes Iran’s nuclear installations, our willingness to openly oppose the administration will weigh in our favor. It will impact our neighbors’ willingness to cooperate in action aimed at removing Iran’s nuclear sword from their necks and ours.

By fighting the deal, Israel has also worked to shape our relations with the US in a favorable way both in the short and long term.

Obama has another year and four months in office. (503 days, but who’s counting?) Even before the fight over his nuclear deal began in earnest, Obama made clear that he intends to use his remaining time in office to undermine the US-Israel alliance and to weaken Israel internationally.

In the first instance, his Democratic and progressive surrogates’ anti-Semitic assaults against New York Democratic Sen. Charles Schumer, and the Justice Department’s coincidental indictment of pro-Israel New Jersey Democratic Sen. Robert Menendez communicated a clear message to Democratic lawmakers: Any Democrat who supports Israel against Obama will be targeted.

By acting in this way, Obama has communicated the clear goal of transforming support for Israel into the foreign policy equivalent of opposing abortion: a Republicans-only position.

Internationally, there can be little doubt that until Obama leaves office, he will seek to harm Israel and the UN. He may as well seek to harm our economy by quietly instituting administrative trade barriers with the US and Europe.

Israel’s fight against Obama’s nuclear deal has diminished Obama’s ability to use his full power to harm it while preparing the ground for relations to be repaired under his successor.

Until Netanyahu spoke before the joint houses of Congress in March, Obama’s nuclear deal was largely outside the American discourse. The fierce public debate began only after Netanyahu’s address. True, on Wednesday Obama got the support of his 34th Democratic senator and so blocked Israel’s efforts to convince Congress to vote down the deal. But his victory will be Pyrrhic.

Obama’s success will backfire first and foremost because thanks to Netanyahu’s move to spearhead the public debate in the US, today two-thirds of Americans oppose the deal. Since Iran will waste no time proving just how devastating a mistake Obama and his fellow Democrats have just made, Obama’s success makes him far less free to enact further steps against Israel than he was before the deal was concluded. The public no longer will give him the benefit of the doubt.

Moreover, since the deal is as bad as its opponents say it is, and given that most Americans oppose it, Obama’s successor will face no impediments in canceling the deal and adopting a new policy towards Israel and Iran.

Then there are Obama’s Democratic followers in Congress.

Today some commentators argue that Obama’s victory over opponents of his nuclear deal – first and foremost AIPAC – spells the demise of the pro-Israel lobby in the US.

Thankfully, they are mistaken.

Just as it failed to prevent then-president Ronald Reagan from selling AWACs to Saudi Arabia in 1981, so AIPAC had no chance of preventing Obama from moving ahead with his Iran deal.

AIPAC has never had the power to defeat a president intent on advancing an anti-Israel policy.

We will only be able to measure AIPAC’s power after the 2016 elections.

Given that the nuclear pact will fail, there will be plenty of Democrats challengers who will be eager to use their Democratic incumbent opponents’ support for Obama’s nuclear madness against them. AIPAC’s public fight against the deal has set the conditions for it to extract a political price from its supporters who preferred Obama to US national security.

If AIPAC extracts a price from key Democratic lawmakers who played crucial roles in approving the nuclear deal with Iran, it will prevent Obama from turning support for Israel into a partisan issue and emerge strengthened from the fight.

On Wednesday, after Maryland’s Sen. Barbara Mikulski became the 34th senator to support Obama’s nuclear deal, PBS’s senior anchorwoman Gwen Ifill tweeted, “Take that, Bibi.”

Obama’s win is Bibi’s loss. Bibi failed to convince 12 Democratic senators and 44 Democratic congressmen to vote against the head of their party. But by fighting against this deal, Netanyahu removed the main obstacle that kept Israel from taking action that will prevent Iran from going nuclear. He reduced Obama’s power to harm Israel.

The fight strengthened American and American- Jewish opposition to the nuclear deal, paving the way for a Democratic renewal after Obama leaves office. And finally, Israel’s public battle against Obama’s deal paved the way its abrogation by his successor.

All in all, a rather glorious defeat.