THE attempt to find some common ground over Syria dominated the talks on May 3rd between Recep Tayyip Erdogan and Vladimir Putin. But the meeting between the Turkish and Russian presidents also touched on another subject of concern to Turkey’s NATO allies. A deal has been agreed in principle for Russia to sell Turkey its potent S-400 long-range air-defence system. A price has yet to be agreed. But as both strongmen have shown with their steady reconciliation over the past year, enough political will can make most plans lift off.

At a time when tensions between NATO and Russia are at their highest since the cold war, the purchase, if it goes ahead, will be seen as a calculated snub to the alliance. It will also confirm the impression of recent years that Mr Erdogan is happy for Turkey to become, in effect, a semi-detached member of NATO.

Turkey first began pushing NATO’s buttons in this way when it announced its intention in 2013 to acquire a Chinese air- and missile-defence system instead of American or European kit. By doing so, Turkey was flouting European Union and American weapons sanctions against China. It would also have meant buying a system that could not be integrated into NATO’s wider missile-defence shield without allowing the Chinese to delve into Western military technology. Turkey gave its reasons for preferring China’s offer as the lower price (about $3.4bn) and better terms on the transfer of intellectual property (IP).

Building up the capabilities of its fast-growing indigenous defence industry has become a priority for Mr Erdogan. Two years ago he declared that Turkey planned to “eliminate external dependency on defence equipment supply” by 2023, and that it wanted to be involved in the design and production of any new defence equipment before then.

What caused Turkey to drop the deal with China later that year is not clear, but the decision was made around the time of the G20 summit in Antalya in southern Turkey. A combination of diplomatic carrots and sticks probably played a part. Douglas Barrie, a military aerospace expert at the International Institute for Strategic Studies in London, thinks that the Chinese may have been unable to hand over the technological know-how Turkey wanted, because much of the IP of their system, based on the S-300, is owned by Russia.

The assumption then was that Turkey would go with MEADS (medium extended air defence system), a joint venture between Lockheed Martin, an American defence company, and MBDA, a European missile consortium. But in April Fikri Isik, Turkey’s defence minister, said that “NATO member countries have not come up with an offer that is financially effective” and that talks with Russia to buy the S-400 were now at a final stage.

The S-400 is one of the best air-defence systems currently made. But Mr Isik accepts that Turkey will not try to integrate it with NATO’s infrastructure. That makes it “a sub-optimal system”, thinks Mr Barrie. Given that the S-400 is also expensive, Turkey’s eagerness to buy it must be because it believes it is getting enough knowledge about the technology it wants and because Mr Erdogan likes demonstrating that he need not bow to the West.

Russia will also benefit from the deal, as the world’s second-biggest arms exporter. China and India, until recently two of its best customers, are ramping up their own production. Russia badly needs new markets for its weapons—and Mr Putin also enjoys thumbing his nose at NATO.