The S-400 missile system during a military parade in Moscow in 2015
© Sputnik Photo Agency, via ReutersThe S-400 missile system on display during a military parade in Moscow in 2015. Western officials are uneasy over Russia’s influence in Turkey, a NATO member
In the clearest sign of his pivot toward Russia and away from NATO and the West, President Recep Tayyip Erdogan announced on Tuesday that Turkey had signed a deal to purchase a Russian surface-to-air missile system.

The deal cements a recent rapprochement with Russia, despite differences over the war in Syria, and comes as Turkey's ties with the United States and European Union have become strained.

It is certain to stir unease in Washington and Brussels, where officials are trying to keep Turkey - a longtime NATO member, and an increasingly unlikely candidate for European Union membership - from entering Russia's sphere of influence.

The deal comes as relations between Russia and the West are at a particularly low point. Tensions escalated in 2014 when Russia annexed Crimea and then began fomenting armed revolt in eastern Ukraine. They have grown still worse as evidence has mounted that Moscow was behind the hacking of the 2016 election in the United States and also tried to interfere in other nations' elections.

Although a prospective missile purchase from Russia was made public several months ago, Mr. Erdogan's announcement was the first confirmation that Turkey had transferred money to pay for the missile system, known as the S-400.

"Signatures have been made for the purchase of S-400s from Russia," Mr. Erdogan said in comments published in several newspapers on Tuesday. "A deposit has also been paid as far as I know."

The purchase of the missile system flies in the face of cooperation within the NATO alliance, which Turkey has belonged to since the early 1950s. NATO does not ban purchases of military hardware from manufacturers outside the American-led alliance, but it does discourage members from buying equipment not compatible with that used by other members.

A NATO official in Brussels, the headquarters of the alliance, said that no NATO member currently operates the Russian missile system and that the alliance had not been informed about the details of the purchase by Turkey.

"What matters for NATO is that the equipment allies acquire is able to operate together," the official said, speaking on the condition of anonymity as required by alliance procedures. "Interoperability of allied armed forces is essential to NATO for the conduct of our operations."

Turkey had earlier planned to buy missiles from China, but that deal fell through under pressure from the United States.

Western arms makers lobbied hard for the expansion of NATO into former Soviet satellite countries after the collapse of Communism. They have since lobbied both new and old NATO member states not to stray outside the alliance for weapons purchases that would cut into their business.

Mr. Erdogan dismissed issues of interoperability, brand loyalties or the geopolitical optics of such a sale. "Nobody has the right to discuss the Turkish republic's independence principles or independent decisions about its defense industry," the daily newspaper Hurriyet reported him as saying.

"We make the decisions about our own independence ourselves," he said. "We are obliged to take safety and security measures in order to defend our country."

Mr. Erdogan's announcement - made to Turkish journalists aboard his presidential jet as he returned from Kazakhstan - appeared timed as a riposte to two judicial cases announced last week in the United States. One is against his presidential bodyguards, who are charged with assaulting protesters when Mr. Erdogan visited Washington this year. The other is against a group of Turks, including a former minister, accused of breaking United States sanctions against Iran.

Mr. Erdogan has angrily criticized both cases.

Yet Turkey has other reasons for the missile purchase. It needs to cultivate good relations with Russia, and it also needs to build its own military defense, said Asli Aydintasbas, a fellow at the European Council on Foreign Relations. "Turkey wants the deal," she said, "and Russia is only too happy to drive a wedge into the NATO alliance."

NATO's collective defense should be sufficient for Turkey; indeed, NATO deployed Patriot missiles there during a rise of tensions with Syria in the past. But Mr. Erdogan has lost trust in the West since last year's failed coup, which he has interpreted as a Western plot to oust him, and appears determined to secure his own defense, Ms. Aydintasbas said.

Military and civilian plotters used jets and tanks to try to seize power last July and bombed several locations, including the Parliament building, before being faced down by loyalist security forces and public demonstrations. Mr. Erdogan narrowly evaded capture.

The transfer of technology from Russia is attractive to Turkey, Ms. Aydintasbas said. Mr. Erdogan has spoken also of his frustration at having requests to the United States for drones turned down, and of his satisfaction that Turkey developed its own.

Mr. Erdogan's announcement of the deal with Russia came after Germany said that it was suspending all major arms exports to Turkey because of the deteriorating human rights situation in the country and the increasingly strained ties.

"We have put on hold all big requests that Turkey sent to us, and these are really not a few," the German foreign minister, Sigmar Gabriel, said during a panel discussion in Berlin on Monday, according to Reuters.

As suspicions toward the West have grown, relations with Russia have warmed, driven by the personal relationship between Mr. Erdogan and President Vladimir V. Putin of Russia. Mr. Erdogan has expressed personal admiration for Mr. Putin, to the consternation of many European and American leaders, if not President Trump.

Mr. Erdogan has also shown a preference for the Russian model, with its sense of restoring a lost empire, returning Turkey to a more independent place in the world and rejecting Western democracy.

After a tense falling out in 2015, when Turkish jets shot down a Russian warplane on Turkey's border with Syria, Mr. Erdogan sought to improve relations with Russia, sending two letters to Mr. Putin and then traveling to Moscow for a meeting in June 2016.

His visit represented a marked shift from the Cold War era, when Turkey was a staunch ally of the West in facing down the Soviet Union. (Turkey shares a border with Georgia, Armenia and Azerbaijan, former Soviet republics that remain, to varying degrees, under Russian influence.) Russian-Turkish rivalry in the Black Sea and the Caucasus dates back centuries.

Mr. Putin, at odds with the West since he annexed Crimea from Ukraine in 2014, also worked hard to patch up relations with Ankara, seeing in Mr. Erdogan a like-minded strongman who shares his distrust of meddling by the West.

The fact that Turkey belongs to NATO, whose unity Moscow has struggled for years to undermine, has only increased Mr. Putin's desire to forge strong relations with Mr. Erdogan despite their differences over the conflict in Syria.

"Mr. Putin and myself are determined on this issue," Mr. Erdogan told journalists about the missile deal.

Last year, Russia and Turkey reached an agreement to revive a suspended natural-gas pipeline project.

The purchase of Russian missiles would take cooperation to a new level, but is not the first time that Turkey has bought military equipment from Russia. It turned to Moscow in the early 1990s to buy military helicopters and armored personnel carriers.

After relations hit a rocky patch over Russia's 1994 war in Chechnya, however, Turkey disappointed hopes in Moscow that it would become a major new market for Russian hardware.

Russia, largely squeezed out of the arms market in Western and Eastern Europe, even in countries that once bought nearly all their weapons from the Soviet Union, has looked for years to NATO'S eastern flank as a promising market and the alliance's weakest link. It has also sold weapons to Greece, another NATO member and to Cyprus, which is not a member of NATO but houses British military bases and effectively serves as an outpost of the alliance.