On Friday, a faction of the Turkish military tried to overthrow presidential strongman Recep Erdogan, leader of the Justice and Development Party and increasingly the man of Turkish politics. They failed; first, they didn’t kill or capture Erdogan in the opening moments of the coup, then they failed to shut off the Internet and media so that Erdogan’s supporters couldn’t rally. A few hours after the coup had begun, it began to unravel as tens of thousands of Turks flooded the streets, captured tanks, killed soldiers, and forced the rest of the putschists to surrender.

It was remarkable how it played out in public: from Erdogan Facetiming the nation to revelations that the putschists were using WhatsApp to coordinate units, this was in every sense a 21st century coup run as though it were the 20th century.

Coups are always high risk affairs: they must, by their nature, involve small numbers of highly motivated, highly organized troops who strike quickly at the heart of power. In the 20th century, it was a simpler job. Coup plotters often grabbed hold of the few means of mass communication: telephone lines, radio stations, television stations, cutting counter-coup forces off from the ready means of counterattack. If successfully blinded, governments often found themselves on the losing end of a coup, unable to rally their superior forces before key elites were captured or killed by the putschists.

But it is not the 20th century. When the Turkish plotters grabbed hold of CNN and state TV, they did not shut off the Internet – leaving the line open for Erdogan to Facetime the counterattack. They did not occupy broadcast stations, coming and going rather than maintaining control of journalists, who promptly lambasted the soldiers as soon as they left.

Once Erdogan emerged onto the scene and began his flight to Istanbul, the tide rapidly turned. It became obvious that this was just a handful of soldiers rather than the whole Turkish army: emboldened, police and protesters alike began to attack putschist positions. For their part, the coup soldiers began to fire back, but they were hopelessly outnumbered; even if they’d emptied their clips into the crowds, they could not hope for victory once Erdogan had mobilized Turks against them.

To understand last Friday, and to look at the trajectory it has now put Turkey onto, we must, of course, look back to the past.

And the tale to tell is how, for hundreds of years now, Turkey has struggled to keep up with the West.

Anatolia itself is resource-rich and agriculturally capable. It is a fine starting position in strategic games that are based on Earth. The northern, southern, and western flanks are sea-fortified, though the west’s shattered island system has meant foes can readily leapfrog from Europe into Anatolia. The east is pocked with high mountain ranges, narrow passes, and desolate landscapes, which, while not wholly fortifying the interior, nevertheless do a good job of slowing down lesser foes.

It is the base that gave rise to the early Hittites; that hosted ancient Troy; that was the richest portion of Roman Asia, and which was the backbone of the thousand year Byzantine Empire. It’s location on major trade routes empowers already naturally rich regimes.

If the Middle East were left totally alone by the rest of the world, it would be dominated by either a power based in Anatolia or one based in Iran.

For many centuries, that was the case. Roman Asia gave way to Byzantine Anatolia, which gave way to Turkic Rum, which coalesced into the Ottoman Empire. United and organized by the Ottomans, Anatolian power hammered at the gates of Vienna.

But those days are long past.

It should not be understated how much damage other Middle Eastern states have done to themselves through environmental degradation; Mesopotamian regimes have long snuffed out the best lands along the Tigris and Euphrates Rivers, while little Lebanon, which once sent ships as far afield as Spain, protects its last cedars as national treasures.

Turkish power did not ebb because Anatolia changed; its natural advantages of the past remain in the present. It is that those natural advantages don’t protect against the kinds of foes that have now risen around it.

Its once enviable position on the trade routes to China has diminished; Europeans spent huge amounts of energy and power trying to bypass Turkish tariffs, discovering, by accident, the New World. Western Europeans were best able to take advantage of the New World, fueling the Industrial Revolution and the Enlightenment that caused their nation-states to race far ahead of the Ottoman Empire in short order.

With their new-found power, they shut the Ottomans out of their modernity. But as their fear of the Turkish menace faded, their strategic worries were replaced by the wonder of what might come after the Ottoman Empire. The “Eastern Question” emerged; Turkey became the Sick Man of Europe, the empire none could let die, lest it upset the European balance of power.

And so the Ottoman Empire lasted longer, and rotted longer, than it otherwise would have.

As European nation-states abandoned their medieval political models and emerged as true nation-states, the Ottomans remained wedded to theirs, their subjects absorbing an increasingly dysfunctional legacy. Old fears of Turkish armies, wedded to anti-Muslim sentiment, kept technological transfer to a minimum; while French, British, German, Italian, and Russian scientists might well war with one another one year, they would readily hold conferences in another.

The Turkish sultan and caliph, claiming supremacy over all Sunni Muslims, advanced most in building elaborate edifices of tradition worship. To justify his existence, he drew deeper and deeper upon myth and history; this stagnated Ottoman thought further, spreading to the vilayets over which he ruled.

By the early 19th century, the empire was tottering; its furthest regions in North Africa were rapidly taken by advancing Europeans or split away under independent regimes. As Europe struggled to maintain some sense of international order, Europeans tolerated the splintering of the Turkish Balkans, as Greece, Bulgaria, Serbia and Albania all violently escaped the Turkish grip.

None of this was lost on Turkish elites. But too many had their fates tied to the sultan, who had his foot permanently in the past.

Then along came the Young Turks.

The 20th century dawned as doomsday for the Ottoman Empire. Europe was struggling to find balance with the rise of Germany and Italy, two powerful nation-states who were unsure of their place in the international realm. What happened to the Ottomans mattered much less in the face of their threat.

A handful of Turkish elites understood they had little time to transform their empire into something as powerful as Germany or Italy. In 1908, they struck.

They had a huge job ahead of them. Their empire was multi-ethnic; Turks were a large proportion of the population, but the outlying provinces were dominated by Arabs, while Anatolia itself was riddled with Armenians, Kurds, Greeks, and others who had over the centuries settled in the cradle of empire. Separatism and ethnic dissent in the age of 20th century nationalism was rife; the state was drained containing so many disparate voices.

The state, too, was deeply inefficient, centered around the personality of the sultan, who led not just politically but as caliph religiously as well. State power was distorted by religious scruples; tradition was difficult, if not impossible, to dislodge, even in the face of ruin. Nearly every elite in the empire had to curry favor with the sultan, sapping their talents when they could have been developing the empire.

They were also technologically behind: while they hadn’t sat the 19th century entirely out, they were decades behind European rivals, leaving them a smaller industrial and technological base to draw upon. Without access to the colonial systems the Europeans were building, they couldn’t develop nearly as quickly; as their empire was pared down, they were left with few geopolitical prizes beyond Mecca and Constantinople.

The young Turks took on the state first, forcing a democratic constitution upon the sultan; this was meant to streamline government power by giving roles to the best rather than merely the nobility. But the rot went deeper than that; democracy wobbled the empire rather than stabilized it, and three Young Turks – the Three Pashas – seized absolute power. Realizing the hour was later than anyone realized for the Ottoman Empire, they decided that only radical and violent action could save their empire.

Through outright dictatorship, the Pashas shunted aside the sultan and his traditionalism and embarked upon a radical change in foreign policy. They sought a major European ally that would trade with them and arm them in the latest military technology; they found only Germany willing, gearing up as Germany was for world war. When World War I began in August 1914, the Ottomans plunged headlong into it, dispatching massed armies against Russia, Serbia, and Greece. This was the price to pay for Germany military know-how: it also gave them cover to carry out their next murderous scheme.

This was the Armenian genocide. To simplify the human equation of Anatolia, the Pashas decided the Armenians had to be exterminated. Under the cover of war, they largely succeeded; today there are no Armenian agitators in Turkey as there are Kurdish ones. But by the time the murdering was done, in 1917, the war was lost. British armies had conquered Iraq, Palestine, and Syria, and were converging on Anatolia itself. The entry of the United States onto the Western Front doomed their German allies.

Despite their efforts, the Young Turks had failed to save their empire; in the chaos of peace, the sultan fled, the Three Pashas went into exile, and the Allied powers carved up the Ottoman domain.

But in the wings was waiting Mustafa Kemal, who would become the “Father of the Turks.”

Shorn of their most troublesome provinces, surviving Turkish elites reorganized to prevent the complete subjugation of their rump state. They rallied behind Mustafa Kemal, one of the few Ottoman commanders with victories under his belt. Kemal and his allies knew quite well that if they were to save Turkey as a country, they had to build a modern nation-state.

Kemal’s military competence defeated Allied forces, especially Greek armies who sought to take western Anatolia, and allowed him to expel more minorities from Anatolia, leaving it more Turkified than ever before. This mostly created a homogenized nation; the Kurdish question would not emerge until later in the 20th century.

This solved one problem: a mostly Turkish nation could now support a state. But other legacies had to be smashed, as well.

Especially that of the caliph.

The geopolitical toxin that is political religion had made the Ottoman domain ill-equipped to face down enemies that had no such handicap. In the 20th century, wars were not won by highly motivated religious fanatics, who had a penchant for getting machine gunned en mass, but by industrialized armies that sought efficiency over all things.

But the long legacy of hosting the caliph meant that many Turks saw Islam as their guiding star, both in their lives and in their politics. Kemal abolished the post as a first step.

But that wouldn’t stop anyone from seeking its restoration, nor would it prevent Turkish reactionaries from wasting precious Turkish power fighting civil wars for it. Knowing he could not readily secularize the whole Turkish nation, Kemal instead focused on one, powerful, narrow institution he could and would wholly dominate: the military.

Full of veterans scarred by defeat after defeat, few officers objected to a policy that would empower their army. By the time Kemal died in 1938, the process was complete: while ostensibly a republic, in the background lurked battalions ready to overthrow any elected official who might restore the Islamist distortions of the past.

Which is more or less the story of Turkey’s 20th century.

The Turkish military helped guide Turkey through both World War II and the Cold War. Wisely avoiding the waste of World War II, Turkish military elites then hitched their star to the United States’s NATO, gaining access to Western military equipment and knowledge while gaining security from the Soviet Union. Along the way, they launched 3 coups and one sort of coup to keep Turkey’s Islamist tendencies from returning.

While the Cold War was on, this didn’t matter to NATO; only Communist coups were a bad thing in those days. But the post-Cold War world caught the West in such a strategic lurch that both NATO and the European Union decided the only sensible thing to do was carry on with the ideological struggle for universal democracy and human liberty.

The Kemalist Turkish republic was never designed with such notions in mind. Understanding the lure of the caliph, and of reactionary Islam, Kemal had fine-tuned the military to course correct the nation-state as it developed into a more wholly secular state. But modern Turkey has never had the resources or power to do that; much of its 20th century was spent well behind the rest of NATO developmentally. The caliph’s long shadow continued in the poorer sections of the country.

This is the shadow that Erdogan emerged from. As both the EU and NATO have pushed for greater democracy, Erdogan has done the politically sensible thing and indulged the Islamist fantasies of many Sunni Turks. It has gained him power; it has also undermined the Turkish state, but in geopolitics, personalities do not always do what’s best for their state.

That Turkey’s economy has exploded in the 21st century has helped; Turkish Islam does not appear to be holding back Turkey. Like China, Turkish Islamism allows a strongman to focus heftily on the easiest forms of development: construction, infrastructure, and industrialization. But once those phases pass, and a knowledge economy becomes the next inevitable step, the limits of Islamism will become just as apparent in the 21st century as they were in the 19th.

That won’t matter to Erdogan, who is old enough that he may die of natural causes long before the consequences of his Islamization of Turkey come to the fore. The failed coup has crippled the Kemalist military establishment; Erdogan will coup-proof his state, and it will be his state, not Turkey’s. Since the key to his power is political Islam, it will mean that Turkey will turn towards political Islam for at least a generation. It may not get very far; powerful secular forces may push back hard against it, especially as a strong middle class emerges. But they will have to wait some time now before they get the upper hand again.