Azerbaijan, a key swing player in the Caucasus, may be losing its balance. Russia, Turkey, Iran and the U.S. all compete for influence in the country, but shifting dynamics in the region are threatening to undermine Baku’s strategy at a time when the Azerbaijani regime is feeling insecure domestically.

On Nov. 27, merely three days after Turkey shot down a Russian military jet, Turkish Foreign Minister Mevlut Cavusoglu visited Baku. On Dec. 3-4, Turkish Prime Minister Ahmet Davutoglu is expected to visit Azerbaijan as well. Following the shooting down of the Russian plane, Azerbaijani officials rushed to proclaim their friendship for both countries and the need to reduce tensions. Azerbaijan, however, is caught in a complex regional web: the country enjoys a close relationship with Turkey, cooperating closely on economic and military matters. Nevertheless, while Russia has a strong alliance with Azerbaijan’s chief rival, Armenia, with Moscow maintaining a military presence inside Armenian territory, the Kremlin has also maintained cooperation with the government in Baku. For Russia, avoiding another war between Azerbaijan and Armenia over Nagorno Karabakh has been a strategic goal, since fighting in the South Caucasus would both create instability along Russia’s southern frontier and potentially draw Russian participation.

Azerbaijan is significant for the U.S., as well as many European governments, both due to the country’s energy reserves and ability to serve as an alternative to Russian energy imports, and its geographic position, on the southern edge of a line of countries that could contain Russia. In fact, on Nov. 23 a U.S. delegation led by Deputy Assistant Secretary of State Bridget Brink met with Azerbaijani President Ilham Aliyev. Iran, which has its own ethnic Azeri minority, also takes an interest in Azerbaijan, though thus far it has been unable to effectively compete with Turkey for influence in Baku. While relations between Tehran and Baku have improved since Iranian President Hassan Rouhani took office, Iran remains primarily an ally of Armenia and Russia.

Azerbaijan’s strategy of balancing between Russia and the West while maintaining close ties with Turkey and a cordial relationship with a preoccupied Iran may be coming to an end as regional dynamics shift. The U.S. would like to contain Russia, but at the same time is happy to see Russia fighting the Islamic State and aiding the Syrian regime’s forces. Turkey, long focused on maintaining security within its borders, may ultimately be forced to project power outside its territory. Iran, previously constrained by sanctions and international isolation, may now be in a stronger position to compete with Turkey and Russia for influence in the Caucasus. Russia has worked to prevent an escalation between Azerbaijan and Armenia, but there are unconfirmed reports that following the shooting down of the Russian plane, Russian President Vladimir Putin ordered his country’s military to put Russian troops near the Turkish-Armenian border on combat readiness. If accurate, this move would worry not only decision-makers in Ankara, but in Baku as well.

These shifts in geopolitical dynamics are taking place just as the regime in Baku is becoming noticeably more insecure about its own position. In mid-October, Azerbaijan’s minister of national security was dismissed from his post. Following this dismissal, high-ranking officials within the National Security Ministry began to be put under arrest or investigation, including heads of department and deputy heads of department with the ranks of colonel and lieutenant colonel. Then, on Nov. 26, Azerbaijani authorities conducted a raid on Nardaran settlement, a village of about 8,000 people near Baku known as a stronghold of radical Shia Islam in Azerbaijan. The authorities claimed that a group called Muslim Unity was armed and wanted to create mass clashes and terrorist attacks in Baku. Two policemen and at least four suspects were killed during the raid, while over a dozen others were arrested. Security operations in the area continued on Dec. 1. While Nardaran has a history of protests, it is unlikely that any group active in the village posed a real threat to the regime, raising the possibility that the government in Baku is assessing that its position is vulnerable. Low energy prices have forced the government to cut expenditures. The Iranian ambassador to Baku denied any Iranian role in the events in Nardaran, but the public denial itself points to tensions over Tehran’s influence inside Azerbaijan.

The government in Baku is visibly worried, both about its internal position and the country’s strategic alignments. As Russia’s role in the Middle East evolves and Turkey responds to changing dynamics in Syria, and as Iran’s position in the region shifts, Azerbaijan will be forced to adjust its strategy.