(CNN) -- The saber-rattling between Iran and Israel conjures fears of mass casualties and a nuclear arms race in the Middle East.
Israel has threatened to attack Iran to stop it from obtaining nuclear weapons. Iran says its nuclear program is for peaceful purposes and has threatened to strike first against enemies who threaten its national interests.
The tough talk makes it easy to forget that Israel and Iran have not always been enemies. The Jews of Israel and Persians of Iran have had a rich and nuanced relationship dating back thousands of years.
They have enjoyed an "overwhelmingly positive connection" for centuries, said Trita Parsi, president of the National Iranian American Council and author of "Treacherous Alliance: The Secret Dealings of Israel, Iran, and the United States."
In fact, Israeli Jews grow up reading a Bible story about the Persian leader Cyrus the Great, who is said to have liberated Jews and allowed them to return from exile to rebuild the temple in Jerusalem, said David Menashri, an Israeli expert on Israeli-Iranian relations.
"In the back of the historical memory of the Israelis, when you speak about Iran, Iran is considered to be a good friend of Israel," he said.
After the birth of the nation of Israel in 1948, the countries enjoyed a "honeymoon" that lasted until just before the 1979 Islamic revolution, said Menashri, professor emeritus of Tel Aviv University and president of the Academic Center of Law and Business in the Israeli city of Ramat Gan.
Before the revolution, when the shah-led monarchy governed Iran, Israel and Iran shared a pro-Western bent. They cooperated overtly and covertly on economic, political and security issues.
Israel viewed Iran as part of its strategy to develop ties with non-Arab states on the region's periphery, such as Turkey and Ethiopia. It also saw Iran as an important way station for Jews fleeing persecution in Iraq, said Uri Bialer, a professor at Hebrew University of Jerusalem.
Israel's ties with Iran were chiefly motivated by "a single word with three letters -- O-I-L," he said.
Iran earned money selling oil to the Jewish state. The shah also saw in Israel another pro-American ally with influence in the United States.
"Under the shah, Israeli-Iranian ties were multilayered and complex," said Haim Malka, a Middle East expert at the Center for Strategic and International Studies in Washington.
"The shah had a similar interest in building strategic ties with a growing military power that had a record of defeating Arab armies, though he was careful not to publicly embrace Israel too warmly," Malka said.
It was "a love affair without marriage," Menashri said, quoting an Iranian diplomat. "You don't need to have a formal contract to have a happy marriage. You are happy together."
Even though Iran never formally recognized Israel, Israel operated a permanent delegation in Iran until the overthrow of the shah in 1979. That event ushered in an Islamic republic led by the Ayatollah Khomeini and marked a turning point in ties between Israel and Iran.
The Islamic republic, led by Shiite clerics in the predominantly Shiite nation, saw Israel as an illegitimate state with no right to exist, certainly not amid Muslim nations.
Despite harsh rhetoric, though, Khomeini "didn't want to get into a confrontation with Israel," said Ervand Abrahamian, a professor of Iranian and Middle Eastern history at Baruch College of the City University of New York.
One reason relations weren't worse in the 1980s: Israel and Iran had a common enemy in Iraq, a country that fought an eight-year war with Iran.
Israel even supplied weapons to Iran to help it fight Iraq, Abrahamian and other analysts say. And Israeli warplanes bombed a nuclear reactor in Iraq in 1981, an act seen as beneficial to both Israel and Iran.
Even as "Khomeini called Israel a 'cancerous tumor,' the Israelis lobbied Washington to boost Iran's defenses and bring Tehran 'back into the Western fold,' " Parsi said.
In the years after the Iran-Iraq war, however, Israel began to regard Iran and its support of global terror as a chief threat.
The Islamic republic supported anti-Israeli movements such as Hezbollah in Lebanon and Hamas in Gaza -- groups that Israel and the United States classify as terrorist organizations. Iran also stirred anxiety in Israel by revving up its nuclear program.
Iran harbored ambitions to lead the Muslim world in the fight to liberate Palestinians and wrest Jerusalem, one of Islam's holy cities and Judaism's holiest city, from Israel, said Vali Nasr, the author of the "Shia Revival."
Yet Iran maintained a pragmatic instinct, said Parsi, who cited a 2003 Iranian idea to lower the political temperatures and stave off Iran's isolation.
"Much like Malaysia, Iran would be an Islamic state that did not formally recognize Israel and would occasionally criticize Israeli policies, but would refrain from directly confronting Israel. Iran would get out of Israel's hair in return for an end to Israeli pressure on the United States to isolate and contain Iran," Parsi said.
The concept didn't get off the ground.
After he was elected in 2005, Iranian President Mahmoud Ahmadinejad began spouting anti-Israeli and anti-Western rhetoric. He enraged Jews by denying the Holocaust and alarmed them with virulent attacks on Israel.
His rhetoric stoked fears in Israel and elsewhere that a major world leader would want to destroy the Jewish state.
Yet it has been Iran's nuclear program that has raised the prospects of armed conflict.
Israeli Prime Minister Benjamin Netanyahu has said Israel will act to prevent Iran from obtaining nuclear weapons. U.S. President Barack Obama pledged support for Israel this week but also urged more time for diplomacy and harsh sanctions to have an effect.
As the possibility looms of an Israeli military strike on Iranian nuclear sites, the two countries appear to already be engaged in what many have called a shadow war. After Iranian nuclear scientists were assassinated in Tehran, Iran blamed Israel. When attackers targeted Israeli diplomats this year in India, Thailand, Georgia and Azerbaijan, Israel blamed Iran.
Underneath the political tensions, though, some measure of goodwill persists for some.
"Despite three decades of animosity, tens of thousands of Iranian Jews in the United States and Israel still have a strong cultural attachment to Iran," said Malka, the Middle East expert in Washington.
Many Iranian Jews maintain contact with friends and relatives who are among the roughly 20,000 Jews in Iran, Malka said, and Israeli radio beams programming in Farsi inside Iran.
Connections between the two peoples are underscored by the Jewish holiday of Purim, which began Wednesday night. It commemorates a Bible story in which Haman, an adviser to the Persian king, plots unsuccessfully to kill Jews,
The story resonates with Israelis worried about the Iranian president. Many of them compare him to a figure far worse than Haman.
"They speak about him as Hitler," Menashri said.