WASHINGTON — In the Middle East, your enemy's enemy is your friend.

For Israel, Saudi Arabia's growing willingness to confront Iranian influence in the Middle East presents an opening for an awkward alliance. As the kingdom's dynamic new crown prince, Mohammed bin Salman, tries to rally an anti-Iran coalition, Israel — with the blessing of the Trump administration — is presenting itself as a willing and able partner.

The appetite for cooperation between two of America's closest allies in the Middle East has grown in recent years as their security interests have dovetailed. Both Israel and Saudi Arabia view Iran's growing influence in the region as an existential threat and want to squash militant Islamist groups like ISIS and Iran's main proxy, Hezbollah.

A U.S. official who witnessed a Saudi and Israeli official hold a closed-door meeting together recently said such informal meetings have been taking place for "at least five years."

Officials say Israelis are cautiously optimistic about the budding friendship with the revamped Saudi regime, but observers identify many risks.

The crown prince, while seen by many as a reformer, is also widely viewed as erratic.

For example, the abrupt resignation of Lebanese Prime Minister Saad al-Hariri last week after Saudi leaders summoned him to Saudi Arabia has essentially left Lebanon, Israel's neighbor to the north, vulnerable to total Hezbollah domination.

Daniel Shapiro, the U.S. ambassador to Israel until January, said that while Israelis are encouraged by the prince's swift actions, "He is inexperienced, young and kind of impulsive, and in the case of Lebanon, there's a sense he may be setting Israel up to do the dirty work."

Related: Saudi Arabia and Iran Battle for Power in the Middle East

An Israeli-Saudi alliance would also be vastly unpopular on the Arab street given Israel's actions in the West Bank and Gaza.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"An alliance with Israel will definitely hurt the Saudis and their allies," said Hassan Hassan, an author and Middle East expert with the Tahrir Institute for Middle East Policy in Washington. "It makes sense for them on the geopolitical level but not internally or on the social level."

"The paradox is that Saudi Arabia and others want to counter Iran through an alliance with Israel, but failing to stand up to Iran and then align with Israel is ticking all the boxes of a bad policy."

'It's an open secret'

In the late 1970s, Arab governments became less concerned with their conflict with Israel and more focused on modernization and political continuity, leaving dormant the question of Palestinian statehood. Meanwhile, Israeli and Saudi officials began realizing the potential for collaboration as their concerns converged during Iran's 1979 Islamic Revolution. The Sunni kingdom and the Jewish state were both unhappy about the hostile new Shiite theocracy in the neighborhood.

"The Saudi-Israeli intelligence relationship has been there in an outline — an exchange of views — for decades," said Simon Henderson, director of the gulf and energy policy program at the Washington Institute for Near East Policy. "It has its own life because of Iran. That's the umbrella reason."

While Saudi Arabia's government has since come to view the Israelis as a potential partner in the region, it continues to resist an open diplomatic embrace, preferring off-the-record consultations.

"It's an open secret," Shapiro said. "There is a considerable amounts of quiet, behind-the-scenes coordination between them — intelligence channels and other security channels — and it remains quiet because Israel is still unpopular in those Arab states."

Three former U.S. officials told NBC News that U.S. diplomats engage with both sides with the assumption that the two parties speak directly. One official said that Israel and Saudi Arabia had presented virtually identical points of concern while negotiations were underway on the Obama administration's nuclear agreement with Iran.

Saudi Crown Prince Mohammed bin Salman. Fayez Nureldine / AFP - Getty Images

America's relationship with both Saudi Arabia and Israel soured as a result of the agreement — a deal Trump has all but repudiated as part of his administration's broader crackdown on Iran.

His administration has also made significant overtures to foster closer cooperation between the Saudis and the Israelis.

Jared Kushner, the president's son-in-law and adviser, has a close personal relationship with both Saudi Arabia's crown prince and Israeli Prime Minister Benjamin Netanyahu. And he continues to press Saudi Arabia to help crack down on Hezbollah — which continues to pose major security concerns for Israel.

Saudi Arabia and Israel were the first and second stops, consecutively, on Trump's maiden overseas trip in May. And in a symbolic move, Air Force One traveled directly from Riyadh to Tel Aviv — an unprecedented flight between one-time enemies.

The signs of progress are everywhere. In 2015, Israel announced that it was opening its first representative office in the United Arab Emirates, a less conservative Sunni Arab state. Countries in the region have also explored the idea of suspending a longtime ban on Israeli aircraft over Arab airspace, which would cut hours from flights that are currently required to take lengthy detours.

A number of Israeli officials have been blunt about their desire to embrace Saudi Arabia as a partner and ally. In June, Israel's intelligence and transportation minister, Yisrael Katz, called on Saudi Arabia's King Salman to invite Netanyahu to Riyadh to establish full diplomatic relations.

Avigdor Lieberman, Israel's defense minister, also called for establishing "full diplomatic and economic relations" with Arab states.

When it comes to formal and direct Saudi-Israel talks, U.S. officials say both parties would be inclined to proceed without American involvement. Trump himself sparked concern among intelligence agencies around the world, and particularly in Israel, when reports emerged earlier this year that he had divulged classified intelligence, originally from Israel, to Russian diplomats visiting the Oval Office.

President Donald Trump and first lady Melania Trump wave as they board Air Force One before leaving Riyadh en route to Israel. The president's flight from Riyadh to Tel Aviv on Monday was believed to be the first direct flight between Saudi Arabia and Israel. Bandar Al-Jaloud / Saudi royal Palace via AFP - Getty Images

The stakes are much higher for Saudi Arabia than Israel. The Saudis remain reluctant to publicly acknowledge or accept that relations are, indeed, improving. It's unlikely that any relationship will be formalized in the absence of Palestinian statehood — a condition the Saudis have demanded for years. But under the table, both sides agree that the enemy of your enemy is your friend.

"They both want to see the Iranian advances stopped, they want to see Iranian meddling stopped, they want to see Hezbollah done in," said Roby Barrett, a Gulf expert and author with the Middle East Institute in Washington. "Their interests are almost perfectly aligned."

On Tuesday, Iranian President Hassan Rouhani took an apparent swipe at the Saudis and Israelis and their relationship with the U.S. in a statement to his cabinet about unnamed "superpowers."

"The superpowers' presence in the region is only for marketing their weapons, interfering in the regional market and manipulating the oil price," said Rouhani, according to state media, "and they have always sought their malevolent objectives giving no thought to the interests and benefits of the people of the region, entailing nothing except trouble or predicament for the region."