As America and partnering world powers toil in Vienna to turn Iran into their BFF, our traditional, now jilted, Arab allies are looking for love in all the wrong places.

Can you blame them, though?

Fearing the rise of a new empire ruled by megalomaniacal Persian Shiites, the Saudis, Egyptians and others are seeking alliances with Vladimir Putin, who dreams of his own empire.

Take Egypt. Seeking to enter Putin’s customs union, Cairo now contemplates switching to rubles in order to buy Russian wheat. Egypt plans to join the Eurasian Economic Union by the end of next year — a trading bloc that for now includes only Russian satellites like Kazakhstan, Belarus and Armenia.

Oh, and the Egyptian army once again is buying Russian-made tanks, guns and MiG fighter jets, as well as Chinese clones.

That’s a total reversal of one of the Cold War’s major coups, when, almost overnight, the Soviet-dependent Egyptian army turned to US-made planes and tanks in the late 1970s.

Cairo also switched allegiances. After Washington brokered an Egyptian-Israeli peace treaty, the most populous Arab country turned into a trusted American ally.

And now we’re beginning to see a reversal. Egyptian President Abdel Fattah al-Sisi suspects that the United States no longer has his back, so he’s turning east.

At least Sisi has some memories of being part of the Soviet bloc. The Saudis don’t.

Riyadh has depended on American protection for more than half a century, returning the favor by guaranteeing relative stability in global energy markets (except for a spell during the Carter years).

Yet now the Saudis, too, are seeking Russia’s friendship.

Two weeks ago, Riyadh’s newly minted deputy crown prince, Mohammed bin Salman, popped up in St. Petersburg for an international economic conference.

A 29-year-old Saudi prince — a defense minister, King Salman’s favorite son and a strong candidate to succeed him — doesn’t come to Russia just to see the beautiful churches of St. Petersburg. Mohammed was there to make a statement, and also to sign deals — including, most importantly, in nuclear technology.

Why would Saudis seek help in developing nuclear-energy technology? Surely not because they lack home-grown energy resources.

And why in the world would Riyadh turn to Russia, of all places, for help? After all, both countries rely on oil exports to maintain their economies, so they’re fierce competitors. (The Saudis must’ve been furious when Russia recently surpassed them as the largest oil exporter to China.)

Nevertheless, the Saudis are increasingly dismayed at America’s huge strides in befriending their regional rival, Iran. In official and semi-official statements, Riyadh has made clear its intention to match Iran’s nuclear progress step for step. Surely America won’t help them in that pursuit.

Until recently, the Saudis have mostly relied on the United States for all of their defense needs. Now they’re playing catchup: Public bravado aside, the Saudis are light years behind Iran in developing nuclear capability.

But they have money, and Riyadh has reportedly allocated $80 billion to fund its attempt to match Iran’s nukes in the next two decades.

All for peaceful purposes, of course. Just like Iran.

In the process, the Saudis will likely need to improve relations with anyone who’ll help in speeding up their nuclear pursuit: Russia, China, Pakistan, et al.

As American and Iranian diplomats itch to sign an oh-so-historic nuclear deal, our traditional allies are looking anywhere but to America for friendship.

It’s a desperate pursuit. Egypt would much rather bank on the old, reliable American dollar than on the volatile ruble, to say nothing of the value of having the US military train its officers. And Saudi Arabia is more comfortable doing business with America than with Russia or China.

But, as Israeli Defense Minister Moshe Yaalon said this week, Washington now sees Iran as the solution, while Israel — and America’s traditional Arab allies — see it as the problem.

We’re yet to witness any reciprocation for our efforts to befriend Iran. (Starting with an end to Tehran’s “death to America” chants, maybe?)

Meanwhile, our nuclear diplomacy, possibly culminating in an agreement this week, is a great lesson in how to lose friends and stop influencing people.