If one wonders how the majority Muslim country of Azerbaijan came to such a rich alliance with Israel today, one need look no further than the Red Village, a tiny river conclave in the mountainous region of Quba. There, for centuries, a Jewish community has thrived amid a Muslim population. Today about 5,000 Jews have settled in the village, which boasts three schools and three synagogues. And the language of Hebrew, the artifacts of the Jewish faith and the rich tapestry of Azerbaijani woven carpets all blend together in a lasting tribute to the cultural tolerance this country has achieved.

Arye Gut, an Israeli scholar of Azerbaijani descent, wrote a recent essay describing the unique atmosphere of multiculturalism that has blossomed in the former Soviet republic.

“Respect and tolerance for national minorities has played a vital role in the development of the country from antiquity to the days of the Silk Road to modernity. Minorities, as well as women, have been ubiquitous in Azerbaijani government since its independence from the Soviet Union,” he noted in his essay in The Hill newspaper.

Azerbaijan has made a concerted effort to create and foster the necessary political and social conditions for developing and strengthening the country’s traditions of multiculturalism and tolerance,” he added. “Time and again, Azerbaijan has demonstrated that harmony is possible, and issues can be resolved without resorting to violence or strife.”

Legend has it that Jewish settlers first reached the Quba region back in the 13th century. But the cementing of two cultures really took root in 1742, when the leader of Quba, Huseynali Khan, and his son, Feteli, gave their blessing to Jewish settlers to form a permanent community. The Khans offered their protection to the village, vowing that any attack seen from across the river would summon an army of protection.

That bond of trust has grown over the centuries, and today has translated into a larger diplomatic alliance between Azerbaijan and Israel that began a quarter of a century ago. Israel opened the door in late 1991, with one of the first declarations in the world recognizing Azerbaijan as an independent country after the fall of the Soviet Union.

Diplomatic and economic ties grew rapidly over the years, as both countries shared a deep concern about Iran’s efforts to export Islamist extremism and develop nuclear weapons. Israeli Prime Minister Benjamin Netanyahu made the first official state visit to Baku in 1997 in a sign of how warm relations between the two countries were becoming.

Commerce and trade flourished, with Israel becoming a major importer of Azerbaijan oil and Israel ’s technology industry aiding Baku with such projects as telecommunications infrastructure.

Increased security ties have followed in the years since. Shortly after the Sept. 11, 2001, terror attacks in America, Israel and Azerbaijan declared they shared a common interest in fighting global terrorism, and they forged an intelligence and security alliance that has flourished over the last decade.

That alliance led to the thwarting of a major terror attack planned in 2008 by extremists on the Israeli embassy in Baku and the arrests of 22 people accused of plotting attacks in 2012 against Israeli and U.S. interests in Azerbaijan.

In 2009 Israeli President Shimon Peres also visited Baku, launching a new era of cooperation. And in 2013 Mr. Peres welcomed a high-ranking Azeri delegation to his country to talk about the shared concerns a nuclearized Iran posed for the world.

The Israeli president’s comments that day offered a succinct explanation of how two seemingly odd bedfellows became such strong global allies.

“I know the policy of Azerbaijan is of peace, friendship, development but also of independence. With your unique geographic location, there is no doubt that you already are, and will continue to be, a key country in this part of the world. Azerbaijan takes a clear stand against terror, against war,” the Israeli leader explained.