Turkey has risked the anger of the United States and its fellow NATO members by signing a contract with Russia to buy a missile defense system.

Turkish President Recep Tayyip Erdogan told Turkish media on Tuesday that Ankara had put down a deposit on the Russian-made S-400 missile batteries, a system that can - according to the manufacturers - shoot down up to 80 targets at the same time, and has a range of 400 kilometers (248 miles).

Washington had long been warning Ankara against this purchase, and made increasingly disgruntled diplomatic noises about it. Ben Cardin, the top Democrat on the US Senate's foreign relations committee, suggested that the purchase could violate US sanctions against Russia.

Read more: Özdemir: Erdogan wants to establish Turkey in Germany

For its part, Moscow remained sanguine in response. Vladimir Kozhin, an aide to Russian President Vladimir Putin, told the Russian state news agency TASS, "I can assure you that all the decisions made for this contract strictly comply with our strategic interests. In this regard, the reaction of some Western countries that are trying to put pressure on Turkey is completely understandable to us."

Russians at the top

For NATO, the trouble with the S-400 weapons system is that it is not technologically compatible with the systems it has in place in Turkey - in other words, Erdogan seems to have decided to build a military capacity independent of NATO. "It makes sense [for the Turkish government]," explained Guney Yildiz, Turkey specialist at the European Council on Foreign Relations (ECFR), "because if everything is integrated with NATO, NATO commanders have full control over Turkish military systems."

Erdogan and Putin appear to have found much in common

On the other hand, a Russian missile system also means Russian control.

"It is a very significant development," said Marc Pierini, former EU diplomat and analyst at Carnegie Europe. "This is a missile defense system that is going to be hosted by the Turkish air force, and the Turkish air force has no experience of anti-missile systems, therefore it is going to come with a significant number of Russian advisors, trainers, and operators and so on. So at the top of the Turkish air force defense architecture, you're going to have Russians."

Yildiz believes that a nationally controlled defense system has become a strategic priority for the upper echelons of the Turkish government in recent years.

"They feel they might need a non-NATO air defense system in case they come under attack by some factions in their own military," he said. "Turkey was the scene of an attempted coup last year, when Turkish fighter jets were bombing Turkish institutions."

Yildiz pointed out that there have been signs of US jealousy about Turkey's arms deals before. He remembered that a similar narrative played out over Ankara's attempts to buy a Chinese missile system a few years ago, when US diplomats managed to successfully dissuade the Turks. "But since then several things have changed," said Yildiz.

"The US left a vacuum in the Middle East and Turkey tried to fill it in Syria and elsewhere by trying to directly confront Russia and Iran, and it failed really badly."

Tit-for-tat weapons deals

The low-point of this attempt at regional self-assertion came when Turkey shot down a Russian warplane that had encroached on its territory in late 2015 - which makes the new rapprochement more surprising.

Read more: Russia, Turkey agree to reinvigorate relations after diplomatic row

"If you'd asked me six months ago I would've said that it was unthinkable that Turkey chooses to purchase S-400 batteries - so this does mark a significant change in Turkey's approach," said Ozgur Unluhisarcikli, director of the German Marshall Fund's office in Ankara.

Since then, Ankara has changed tack, "pivoted away" from the West, as the jargon goes, and is now seeking regional allies anywhere it can - i.e. Russia. Not only that, Turkey is not exactly pleased by the way the US has been arming and training Kurdish YPG fighters in Syria.

Sigmar Gabriel's new tough line has not gone down well in Ankara

Meanwhile, as if to give Turkey even more reason to shop elsewhere, German Foreign Minister Sigmar Gabriel confirmed this week that Germany would put all arms exports to Turkey "on hold," because of the tensions between the two countries.

Read more: Sigmar Gabriel: 'Turkey will never join EU under Erdogan'

The response from Ankara was prickly: "Germany should keep its security concerns out of political discussions," said Europe Minister Omer Celik, arguing that the decision would weaken Turkey's fight against terrorism - or against Erdogan's enemies at home, some might say. In any case, the move has added spice to Germany's strange, paradoxical new relationship with Turkey - a major trading partner and biggest political adversary.

This all helps Russia's cause, according to Unluhisarcikli. "Russia has discovered that it can influence Turkish foreign policy through supporting Turkey's military industry," he said. "And if the United States and European Union are unwilling to do the same thing, then actually Turkey might feel compelled to move away from the western orbit and closer to Russia. Russia has a very clear strategy of driving a wedge between Turkey and the United States, and particularly between Turkey and Germany."