Israeli Prime Minister Benjamin Netanyahu attends the weekly cabinet meeting at his office in Jerusalem on Aug. 31, 2015. (Ronen Zvulun/Reuters)

No political leader fought longer or harder against the Iran nuclear deal than Israeli Prime Minister Benjamin Netanyahu, who appears to have suffered the worst foreign policy ­defeat of his career following the announcement that President Obama has secured enough votes in the Senate to preserve the pact.

Yet senior Israeli officials close to Netanyahu are saying that their prime minister has not failed — but won, in a way.

Netanyahu has waged diplomatic war against Iran’s nuclear ambitions through four terms in office, warning that Iran was racing toward a bomb that would pose an existential threat to the Jewish state.

Stopping Obama’s Iran deal in Congress was his overarching ­objective, his chance for a Churchillian moment. Stopping the Iran pact was more important, say his political opponents, than maintaining good relations with an American president, unpopular in Israel, and the United States, Israel’s most steadfast and generous ally.

With a looming defeat in Congress, Netanyahu’s aides and allies now say the prime minister and his closest adviser, Ron Dermer, Israel’s American-born ambassador to the United States, never really believed they could stop the deal in Congress — they only wanted to alert the world how dangerous Iran is.

In a speech Sept. 2, Secretary of State John Kerry had harsh words for lawmakers opposed to the Iran nuclear deal, saying the United States would "pay an immeasurable price" on the world stage if the deal was blocked. (AP)

It may not matter much at home that the Israelis’ spin does not match previous assertions by Netanyahu, who said the deal could be defeated in Congress. It was the reason, the prime minister said, that he accepted an invitation by the Republican leadership to address Congress in March.

Netanyahu himself has been conspicuously quiet, making no public comments Wednesday or Thursday.

“A solid majority in Congress and among the American people” agrees with Netanyahu’s assertion that the deal is a bad one, a top Israeli official close to Netanyahu said.

Yet recent polling is not so definitive. According to a survey released this week by the University of Maryland’s Program for Public Consultation, Americans narrowly support the deal, with 52 percent wanting Congress to approve it and 47 percent wanting the pact rejected. Other polls have shown greater opposition.

Israeli officials promise that Netanyahu will fight on, but it is not clear how or in what forum.

“The prime minister has a responsibility to point out the flaws of an agreement that endangers Israel, the region and the world — and he will continue to do so,” one senior Israeli official vowed.

The same aides and allies say that Netanyahu is playing a longer game, that the deal is so unpopular now that the next president will abandon, change or undermine it. Republican candidates for president, including Donald Trump and Jeb Bush, have vigorously opposed the deal. Democratic front-runner Hillary Rodham Clinton announced support.

Where lawmakers stand on the Iran deal

Finally, officials here predict that when the dust settles, Israel will receive a windfall in new, advanced weaponry — including the most modern aircraft and missile technology — from members of Congress eager to show their pro-Israel bona fides and demonstrate that they remain steadfast enemies of Iran, even if some may have backed Obama on the nuclear pact.

“Look at how they are spinning it. It’s not a defeat; it’s a success. And based on opposition in Congress and some polling in the United States, the spin is technically correct,” said Yossi Alpher, a political analyst and author of “Periphery: Israel’s Search for Middle East Allies.”

When the news cycle shifts in coming weeks to arms packages, economic aid and proclamations of U.S. support, “Netanyahu will be able to say, ‘My opposition didn’t cost us a thing,’ ” Alpher said.

“Netanyahu’s playing it cool,” he said.

“If we pay attention, we would have noticed that for the last week or two, Netanyahu has lowered his rhetoric. He’s a little calmer, and the reason is that it became clear to him — if he ever thought he had a good chance — that an override of the veto was not going to happen,” said Yehuda Ben Meir, a senior research fellow at the Institute for National Security Studies in Tel Aviv.

Barak Ravid, diplomatic correspondent for the Israeli newspaper Haaretz, wrote on Thursday, “Netanyahu knowingly or unknowingly embarked on a futile course that led him to a resounding debacle in the arena most dear to him.”

Ravid reported that contrary to the spin, in “recent weeks, Netanyahu has told cabinet ministers, American Jewish leaders and journalists that he believes there is a chance to block the nuclear accord in Congress. Dermer, who met more than 200 senators and congressmen in recent months, also radiated optimism.”

Some Israeli analysts also wonder what Netanyahu’s opposition will cost Israel and American Jews.

Robert Wexler, a former Democratic congressman from Florida who now heads the S. Daniel Abraham Center for Middle East Peace, said that Netanyahu “compromised the efforts of his own allies” in Washington when he “thrust himself into American politics without understanding the consequences of his actions.”

Wexler faulted Netanyahu for, in effect, “requesting that the American Jewish community rise up against an American president.”

Domestically, the prime minister might not pay a price for his defeat, if it can be called that. Instead, he may be seen as Israel’s great defender. Public opinion about the loss in Congress is still evolving here; many ordinary Israelis seem to think that there’s still a chance of killing the deal.

The front-page headline Thursday in Yedioth Ahronoth, Israel’s largest paid newspaper, was “Achievement for Obama, Blow to Netanyahu.” The headline in Israel Hayom, a free paper with a huge circulation that is owned by the prime minister’s close friend, the billionaire U.S. casino magnate Sheldon Adelson, was, “Official: A Majority in U.S. Agrees With Us.”

Netanyahu’s political opponents also opposed the Iran deal but decried Netanyahu’s confrontational approach. Now they appear ready to move on.

“In light of the new political situation and the failure of Netanyahu’s path, we must safeguard Israel’s security by building a strong regional force with U.S. backing,” said Isaac Herzog, leader of the opposition in the Israeli parliament.

Yair Lapid, former finance minister and a leading opposition lawmaker, said it was time to repair the damage done to U.S.-
Israeli relations and “to remember who our friends are.”

“Throughout this saga, I kept saying we need to remember there will be a ‘day after,’ and so as quickly as possible, the special relationship between the United States and Israel needs to be rehabilitated,” said Lapid, who called the fight over the deal “so partisan, so harsh.”

Obama secures votes to protect Iran nuclear deal

The oddly wide range of people with opinions on the Iran deal

New poll shows how sharply partisan the debate on Iran deal has become

Today’s coverage from Post correspondents around the world

Carol Morello in Washington and Ruth Eglash in Jerusalem contributed to this report.