The great struggles in the Middle East are tinged with religion: Sunni supremacists in the Islamic State, Shi’a supremacists in Tehran, Arabs and Jews waging war on one another over the old mandate of Palestine, to name just a few.

And yet, not so long ago, many Middle Eastern states were using the language of socialism, nationalism, and even communism – ‘isms’ that brook little competition from religion. Inconsistent, yes, but also truth of a wider trend: once upon a time, many Arab states were actively switching their social glue from Islam to modern ideologies.

Consider the national anthem of the United Arab Emirates, whose notes were penned in 1971 and whose lyrics were written in 1996. Full of socialist and nationalist language, the anthem extols work, Arabism, and the Emirati homeland. The Egyptian Constitution of 1971 cried out for Arab unity, while Qaddafi’s Green Book was an odd hodgepodge of nationalism and socialism. The Palestinian Liberation Organization’s founding charter of 1964 doesn’t even mention Islam.

Algeria practiced Algerian socialism until the 1990s; the largest party today in Tunisia, Nida Tunis, draws heavily from secularism and socialism. Officially Arab socialist states included Mubarak’s Egypt, Saddam’s Iraq, and Assad’s Syria. Even after a communist coup in 1971, Sudan continued to pursue socialism.

Once the United States fretted it was losing the Arab world to communism; now, hardly anyone even mutters the world “socialism.” The Middle East has taken a trajectory that seemed to aim for ideological parity with Europe to one that has gone almost entirely the opposite.

Let’s begin at a beginning: the collapse of the Ottoman Empire.

1919 marked the beginning of the modern era for the Middle East. Prior to that, political systems in the Middle East North Africa region (MENA) had been largely unchanged from time immemorial: either imperial outsiders exploited the region’s trade and resources, or powerful local elites did. Politics was brute but simple: strong powers, whether European, Turkish, Persian, Egyptian, Crusader, or caliphate Arab, provided a measure of security in exchange for the lion’s share of the region’s wealth.

The collapse of the Ottoman Empire began the steady break from that political model. Neither victorious Britain nor France wanted to directly administer Ottoman provinces as colonies; gropingly, both powers understood their form of imperialism was rapidly approaching a condition of diminishing returns. As they finished industrializing, they understood their colonies were more expensive to control than they were worth.

Hence the mandate system: this would enable Europeans time to build up fledgling states staffed by friendly elites in former Ottoman villayets. Such states would then be reliable puppets of their former masters, giving them preferential trade and military deals while managing the restless natives on the cheap.

This mandate system introduced nationalism into Arab political consciousness. Europeans understood the nation-state system was far more powerful and less corrupt than the kingdom and empire systems of old. Because Europeans sought to maximize the power of their puppets, they trained Arab elites in Egypt, Syria, Lebanon, Iraq, and Jordan in these very techniques.

The French, pathologically anti-monarchial, went a step further, introducing republican thought into their territories: only in Morocco did they leave the monarchy intact. The British were perfectly comfortable with kings, installing the Hashemite dynasty to power in Baghdad and Amman and drawing closer to the tribal sheikhs and Omani monarchy of the Persian Gulf.

Which began a process of republic-building in some places and constitutional monarchy building in others.

Both the French and British had a vested interest in building reliable nation-states over the ruins of the Ottoman Empire. Whether they were constitutional monarchies or republics depended on the taste of both the Europeans themselves and the local Arabs. Islam was largely left out of the equation, and even to local elites, this made a great deal of sense.

But why did it make so much sense? The Ottomans had declared themselves the caliphs of all Sunni Muslims, but had lost a very large war against superior European powers. Arab elites wanted to imitate the victorious states that had fielded such vast armies in World War I. They saw Europeans who kept religion subordinate and saw no reason such a formula couldn’t work in their part of the world.

This was the prevailing state of mind until the late 1970s. Arab elites quibbled over which European states to copy rather than if they should at all. For the 1920s and 30s, French and British political models had the upper hand: nationalism, republicanism, and constitutional monarchism. Up until and through World War II, Arab states had no option but to rely upon their colonial and semi-colonial masters: the French, British, and Italians had squarely split up the region. But in the flux of the post-war world, Soviet and American influence surged into the region.

Which introduced yet another secular ideology to the mix: socialism.

Arab elites found they could play the Soviets, Americans, French, and British off one another for their own gain, and began pandering to whatever ideology suited them best. As the Soviets were most aggressive in expanding their influence in the 1950s, various states adopted Arab socialism to please Moscow. Egypt, for its part, was rewarded with vast arms, which it used to expel British influence and to threaten its arch-rival, Israel.

Many Arab elites used the foundation of Israel as a way to anchor their often disparate societies: a key step in nation-building is often defining a national Other, some force or foe that can be a geopolitical foil for the nation. This intense hatred of Israel glued together Arab countries that were still finding their footing. But the wars with Israel were rooted in Arab nationalism and identity, not religion. Too many Arab elites still had memories of the great British armies that had overcome the Ottomans; moreover, Arab elites understood the nuclear rivalry between the Soviet Union and United States could not be overcome through religion.

Such underground religious voices existed, of course, insisting to whoever would listen that Islam held the key to power and security. But they gained little traction in the 50s and 60s; atheist communism seemed on the march, while Western capitalism gave God short shrift. Arab nationalist Gamal Abdel Nasser, after all, have survived invasion by not one but three major powers in the 1956 Suez War. So long as Arab nationalism and socialism could claim development of any kind, Islamism did go anywhere fast.

But that began to change in the 1960s.

First and foremost, Arab nationalism began to totter. The first casualty was the pan-Arabist political project of the United Arab Republic, or UAR, which formed a union between Egypt and Syria that lasted all of 3 years from 1958-61. A Syrian coup undid the union; the next Arab federation, the United Arab Emirates, was more successful, but that was largely because unifying the seven emirates of the Trucial Coast was a far less complicated affair.

After the collapse of the UAR, Arab forces suffered a massive defeat in the 1967 Arab-Israeli War. Arab nationalism, it seemed, could not overcome Israeli might; Islamist voices muttered piety was the missing key. To the increasingly disillusioned Arab masses, many of whom had no memory of the Ottoman Empire or its defeat, such mutterings had salience.

To compound this, both socialism and communism began to lose their veneer in the 1970s in the Arab world. South Yemen, the region’s only properly communist state, was a basket case: much like Africa’s would-be communist countries, South Yemen was hardly short cutting any developing steps by embracing Marxism.

But it was within a non-Arab country, Iran, that Islamism would be given breath.

For Iran was more than ready to begin a political experiment no Arab state could risk.

Iran’s naturally geopolitically powerful position allows it to take bigger risks: failure is far less likely to undo it. This meant that Iranians could be persuaded to try a radically different political model in 1979: political Islam.

The Iranian Shah’s development program had been deeply uneven: vast swathes of Iran had been left out of modernization, while other portions had been displaced. Soviet communism trickled in from the north, whispering that Iranians needed a fairer shake, while Shi’a Islamists offered Iranians equality before both economics and God. With few domestic friends, it was only a matter of time before the Shah was displaced.

But rather than succumb to a communist, nationalist, or socialist, Iran embarked upon an Islamic revolution. This was mostly because the Islamists were the best organized and least expected of all the forces that overthrew the Shah; it was also because all the other ideologies had already been tried and had not delivered the results Iranians wanted. Islam, it was felt, could keep Iran secure from Soviet and American control.

This created shock waves.

Culminating in the 1979 Grand Mosque Siege, the Iran-Iraq War, and the Soviet occupation of Afghanistan.

Iranian-inspired pilgrims tried to seize Saudi Arabia’s Grand Mosque in Mecca; Saddam’s Iraq attacked Iran, hoping to overthrow its revolution; and the mighty USSR took on poor and weak Afghanistan. All of them were wins for the Islamists; all of them proved that political Islam could deliver results.

While the pilgrims were defeated, Saudi Arabia took a harsh rightward turn, codifying much of its tough Sharia laws that are so despised today.

Saddam’s Iraq failed to defeat Iran; in fact, Iran’s Shi’a government was strengthened by the war, using the invasion as a pretext to purge the whole government. Meanwhile, the USSR was humbled in Afghanistan against the holy warriors of Sunni Islam; for once, a powerful European state had been driven out of Islamic territory by direct force.

Which put secularism on the back foot permanently.

From then on, secular regimes could only brace themselves: Islamist forces had the ideological strength to go toe to toe with once formidable dictators. From the standpoint of efficacy, secular regimes could offer stagnate stability but little else: dynamic politics had been ceded to the Islamists.

This is the situation that remains to this day.

So what going ahead? Most likely, the same doom that befell Arab socialism and nationalism.

Political Islam cannot deliver the same results as nation-state based capitalism: Iran’s foundering and Saudi’s stagnation makes that clear. But it will take time for the Arab street to accept that. Another full generation will go by before political Islam is consigned to the dust bin.