It’s been almost a month since the failed coup in Turkey, yet the mystery persists. Who was behind it and why did it take place? The only hard evidence as to the intentions of the putschists is of course the statement read on television the very night of the coup, but that statement was carefully crafted to hide its origins and intentions. It appealed to the founding values of the Turkish Republic, nominally shared by all.

Then came the official theory from President Erdoğan: the blame should be squarely placed upon the Gulen movement, directed from Pennsylvania in the United States by a reclusive cleric with whom Erdoǧan himself had been close in the past—but with whom he has broken in an increasingly ruthless conflagration. Gulen openly leads a vast network of schools and charities but is widely reputed to combine those with a secret network infiltrated deep within the state apparatus in Turkey. In 1999 Turkish television aired a secretly taped sermon where Gulen told his followers (he has disputed the authenticity of the tape): “You must move in the arteries of the system without anyone noticing your existence until you reach all the power center." To move before such time as they had gotten hold of all state power from within "would be too early, like breaking an egg without waiting the full forty days for it to hatch. It would be like killing the chick inside.”

Politically, Gulen is a strong nationalist, roughly aligned with the United States and the European Union on foreign policy. Gulenism is very much predicated on the role of education and entrepreneurship in a market-driven economy. It sees Islamic and Western values as fundamentally compatible. EU accession would solidify these elements of the Turkish regime and help coordination between different chapters of the organization across Europe. Gulen himself takes a hardline critical stance on Russia and Iran and at times has been supportive of Israel, speaking against those who take a confrontational approach. According to Aykan Erdemir, a former member of the Turkish Parliament, Gulen "is unequivocally a pro-European Union and Atlantic person, a free marketeer and a pragmatist on Israel."

Only days later the plot thickened yet further when Erdoğan stated in a television interview that final responsibility lay not with Gulen but with a "superior spirit" operating above him—a code word used often in the past to refer to the West. The enormity of the coup seemed to necessitate the work of an all-powerful entity and some joked that perhaps the "superior spirit" was Erdoǧan himself.

The mystery has a lot to do with a sense that the coup happened precisely when it seemed least plausible. To my knowledge, there was no hint of tension between the government and the military establishment. Earlier traumatic purges and trials had voided the political will to stir things up, so officers could not have been particularly afraid of radical changes ahead. For twenty years the Turkish Armed Forces, under different governments, has expelled hundreds of officers accused of Gulenist sympathies. The process was often repeated, but was always mostly inefficient, so developed was the movement's ability to cover its traces. There was no indication that things would substantially change in the future. The extent of the coup and its ability to go undetected clearly show that the Gulenist network was under no clear and immediate danger of being rooted out of the army.

Erdoğan himself was never keen on assuming that the military could have been infiltrated by forces aiming to depose him. But that does not mean that things were everywhere quiet. In the months and weeks before, Turkey had been engulfed by successive shifts in its foreign policy orientation, causing much anguish and agitation. And that's the context in which the coup should be interpreted.

In my political visits to Ankara over the last three years I could witness the increasing level of anxiety. First, relations with Brussels were getting worse every year, something only the mutual need to address the severe refugee crisis could hide. Second, the pledge made early on in the Syrian civil war to depose Assad was coming under unbearable strain. Over the last few months, as Washington made its peace with the idea of keeping Assad in power, it was clear that Turkey would not be able to stay the course. Many people in Ankara thought that Turkey was encouraged to confront Assad and then Russia by the West only to be abandoned when it did. Former Prime Minister Davutoğlu was replaced in part to open the way for a complete shift in Ankara's Syria policy. Like every shift in foreign policy, this one also opened up opportunities. A rapprochement with Russia would most certainly follow if the major bone of contention between them was now removed. Davutoğlu, incidentally, always looked very coldly towards Moscow, which is all the more remarkable as he is someone who likes to try every geopolitical possibility at least once.

Once Davutoğlu had been replaced, Erdoğan moved quickly to mend ties with Russia. At the end of June he apologized to Putin for the downing of a Russian bomber last year that had poisoned relations between the two countries. The apology took most people by surprise, especially because Erdoğan was now claiming that Turkey never intended to shoot down the plane. Then, just three days before the coup, there were widespread reports that Turkey was withdrawing its intelligence officers from Aleppo, seemingly giving up on efforts against the regime in Syria. The succession of events, culminating in the failed coup, was hardly a coincidence.

The Russia question has always been an important one inside the Turkish military. Some of the Kemalist officers see Russia as a partner in resisting Western global hegemony. They point to the beginnings of the Turkish Republic and the support it received from the Soviet Union. Returning to the original spirit of Kemalism would mean for them a break with Western ideology and a turn towards a planned, socialist economic policy, now on the model of the developmental state. The Erdoğan regime seems to have moved some distance in this direction, in which it was vehemently opposed by Gulen and his followers. Some in Ankara go so far as advocating Turkish membership in the Shanghai Cooperation Organization, so as to more closely align its foreign policy with Russia and China. Many others remember the strong rivalry between the Ottoman and Russian empires and think that without support from Western capitals Turkey will be too vulnerable to Russian power. Countries, especially large ones, move very slowly when adapting their foreign policy to new circumstances and the intense rivalry between Turkey and Russia has deep roots in the competition between them for control over the Balkans and the Straits, as well as the corresponding Turkish aspirations for a unified Turkic world from the Adriatic to China.

Resentment against the EU accession process converted many old socialists, nationalists and Islamists into sympathizers of a deep ideological and foreign policy realignment. Turkey was always prone to view the accession process as the sacrifice of a large part of its identity, something that could perhaps be entertained if the benefits were substantial. They never looked substantial enough and now that some have already been collected through greater economic integration, they may start to look paltry. Ironically, if Russia was in the past the source of Western influences within the Ottoman Empire, it is now an important agent pulling Turkey away from the West. Already in 2002 General Tuncer Kilinç of the National Security Council suggested that Turkey should forge a new alliance with Russia and Iran against Europe. At the time this was still a new idea, unpalatable for midst, but that is no longer the case today. Once relatively marginal figures advocating for such a realignment came closer to the mainstream, slowly coalescing around a specific intellectual movement: Eurasianism. As many have pointed out, this seems to complete the strategic square of possibilities for Turkey. Traditionally, when discussing questions of national identity, Turkish intellectuals pointed to one of three directions: to Islam to the South, Europe to the West and the Turkic countries in the Caucasus and Central Asia to the East. After the end of the Cold War a fourth group appeared identifying Russia to the North as main pull for Turkish geopolitics.

The increasing signs that Erdoğan was mulling a new great alliance with Moscow and Tehran set off the alarms. Was this the immediate reason for the failed coup? Turkish journalists have for a few months commented in private that the Turkish Air Force F-16 fighter jet that shot down the Russian bomber was a rogue unit operating outside the chain of command. They were told to keep silent, but on the night of the coup the early news that as many as six F-16 had begun flying over Ankara at very low altitude and with their transponders turned off sounded like a confirmation. In what must be one of the most remarkable facts about the coup, we know that one of the pilots aboard the rebel fighters the night of the coup was in fact the pilot who shot down the Russian plane in November 2015.

The maneuver back then certainly derailed the rapprochement between Ankara and Moscow, but only for a few months. When it was resumed a month ago, there must have been a sense among sectors of the army, mostly associated with the Gulen movement, that time was running up. A number of the implicated officers knew that the coup would endanger Turkish chances of accession to the European Union, but they must have thought that the chances were even lower if nothing was done. Was this the motivation for the coup attempt? There are strong reasons to think so. In a way, then, President Erdoğan may have a point when he says that the attempt was inspired by a "superior spirit." Europe and the United States had nothing to do with it, but the idea of Turkey as part of the Western world may have been the inspiration for the coup plotters.

As a final twist, we should mention the reports about a direct Russian role the night of the failed coup. Fars news agency of Iran (closed linked to the Tehran government) quoted diplomatic sources in Ankara as saying that Turkey's National Intelligence Organization received intelligence from its Russian counterpart that warned of an impending coup. Russia is uniquely placed to have access to intercepted communications from its intelligence bases in the Syrian province of Lattakia. The same sources said that the shift in Erdoğans foreign policy in the weeks before the coup ultimately saved him, as it is not clear the Russians would provide him with the prized intel otherwise. In a press conference on July 21 the Kremlin denied any prior knowledge of the failed coup.

This article was originally published by National Interest.