Not even a month after Azerbaijani counterintelligence services arrested Iranian agents planning terrorist attacks against Israeli diplomats and prominent members of the Jewish community, a network of 22 more Iranian agents were arrested Thursday. These alleged Iranian operatives were hired by the Iranian spy agencies to carry out terrorist attacks against the United States and Israeli targets as well as international oil companies, including BP. All of them are Azerbaijan citizens and were trained by the Iranian Revolutionary Guard Corps. They were paid on a monthly basis.

Recently, Azerbaijan’s ministers of foreign affairs and defense went out of their way to point out that the relations between Baku and Tehran are good, reiterating that Azerbaijan will not allow its territory to be used for a strike against the Iranian nuclear program. However, the ayatollahs appear not to be listening. During the recent visit to Iran by the Azerbaijani Defense Minister Safar Abiyev, the national flag of Azerbaijan was hung upside down—with the green strip symbolizing Islam up top. Iran wants Shiite Azerbaijan to fall in line with its version of religion and not to emphasis Turkic identity, which brings it closer to Turkey. This was the second time the Iranians have offended their neighbors to the north by disrespecting their flag; the first time they did it during the 2005 Tehran visit by President Ilham Aliyev.

Iranians are not only operating terrorist networks on Azerbaijani territory, but are also allegedly behind the 2006 murder of Rafik Tagi, a prominent Azeri writer against whom an Iranian ayatollah issued a fatwa sentencing him to death. The third wave of anti-terrorist arrests since the beginning of the year is seen as a reprisal by Baku to signal to Iran to “play by the rules.”

Relations between Iran and Azerbaijan have been steadily deteriorating as Azerbaijan continues to develop its ties to the United States and the North Atlantic Treaty Organization (NATO). The United States has been leading the effort to impose sanctions to prevent Iran from developing a nuclear weapon. It is possible that Iran is growing more wary and aggressive as sanctions start to bite.

Azerbaijan is not the only country in the region that Iran targets. Iranian intelligence and its Hezbollah subsidiary recently conducted operations against Israeli targets in Tbilisi, Georgia, New Delhi, and Bangkok. According to some experts, Iran is wary of a major confrontation and wants to provoke Israel into smaller confrontations, because it needs an external threat around which it can organize its increasingly dissatisfied population.

Theocrats in Tehran also have a problem with Baku’s secular nature. This is not surprising, as millions of ethnic Azeris live in Iran under ethnic and linguistic discrimination, and may want a freer life like their brethren in Azerbaijan.

Iran is attempting to undermine secular Azerbaijan by paying off preachers in mosques, stirring up religious extremism in the country’s south, beaming in Shia Islamist propaganda broadcasts, and supporting radical organizations. The government in Baku is guarding against radical Shiite organizations that may try to gain political power.

Common interests lead to expanding ties between Azerbaijan and the West. For Baku, this partnership also means increasing options to counter Iranian influence in the region.

The United States should lead the West’s efforts to boost cooperation with Baku, including counterterrorism, intelligence cooperation, and border security improvements. For starters, the Obama Administration should appoint a new, high-profile U.S. Ambassador to Baku after Matthew J. Bryza’s recess appointment has expired. It is time to facilitate a mutually acceptable agreement over the Nagorno–Karabakh issue and engage Azerbaijan as a true strategic partner in the region rather than a supply outpost for Afghanistan or an alternative “gas station” beyond the Persian Gulf.

Azerbaijan may have a significant role in how the conflict with Iran will develop, but more importantly, it is and should remain a long-term friend of the United States.