I am quite used to people smirking into their sleeves when they hear that I’ve just written a book called The Islamic Enlightenment. The really helpful wags say they expect something along the lines of The Wit and Wisdom of Spiro Agnew, which was billed as a collection of all the memorable aphorisms of the former US vice-president, and contained only blank pages.

So, the Islamic Enlightenment — good for a laugh. But we’re all familiar with the serious argument that lies behind the jests; that Islam has not been through an Enlightenment, a Reformation, or any of the other rites of passage that have formed our modernity, and that, ergo, Muslims and modernity are strangers. Not just strangers, but enemies: ever since Gutenberg revolutionised mass printing in the 1450s, pushing the West into the modern age, the Muslims have set their face against innovation. And to be fair, when you take into account the fact that it took some 400 years for movable type to come into general use in the Middle East, and that for much of this period the Ottoman authorities punished book-printing with death, is it any wonder that this bleak view of Muslim improvability has acquired the wide acceptance and legitimacy it currently enjoys?

In fact, rarely has there been a better time to test the belief — widespread in the Trump White House, among Europe’s rising populists, and the Kremlin — that Islamic society is incapable of reforming because it hates progress. Wouldn’t it be awkward if proof were adduced to show that, on the contrary, for long periods in their recent history the central and most influential lands of Islam, having been confronted by dynamic western modernity, embraced that modernity in spades and only lapsed into Islamist recalcitrance after the first world war obliterated them physically and the victorious allies tried to subjugate them politically? But this is what happened in Turkey, Egypt and Iran during the ‘long’ 19th century until 1914.

A key aspect of Islamic modernisation (in Egypt’s case only until the British invasion of 1882) was that the lands in question acted as free, independent agents. Change was not only driven by royal autocrats like Iran’s Crown Prince Abbas Mirza, who reformed the Persian military during the Napoleonic wars, but also by commoners of vision such as the Egyptian administrator and intellectual Rifaa al-Tahtawi, whose conception of progress accommodated steamships, girls’ education and linguistic reform. Another secular visionary was Ibrahim Sinasi, father of Turkish journalism, who peppered the Ottoman government of the early 1860s with impertinent advice on how to deal with Greek irredentists and poured scorn on reactionaries who opposed the introduction of gaslights in Istanbul (the same innovation had met with the same reaction in Georgian London).

Islamic society on the eve of the Napoleonic invasion of Egypt in 1798 had indeed been medieval in many ways, its backwardness perpetuated by despotic government, almost universal illiteracy and the clergy’s monopoly over knowledge. Now change came in a rush. The telegraph, the postal service and table manners arrived almost simultaneously, closely followed by the first polite calls for the crowned head to share power. Theatres of anatomy overturned the prophet’s injunction against cutting up corpses (‘though it may have swallowed the most precious pearl’) and there was an increase in religious scepticism; a photograph of an Istanbul medical school around the middle of the century shows a cohort of medics posing in fezzes amid ghoulish arrangements of human remains. As for the plague, quarantine and hygiene did for this mass killer as they had in Europe two centuries earlier, while slavery was first challenged by a ban on the trade itself (insisted upon by those newbie zealots the British), and ultimately condemned by the decline of the harem, shared habitat of eunuchs and concubines.

The growing integration of the sexes and the decline in polygamy among the new middle class were two manifestations of a broader feminine emancipation. Having begun the century as unlettered chattels of their menfolk, by the first world war a growing number of educated women in Cairo, Istanbul and Tehran were equipped to contribute to an emerging national life. They wrote for feminist journals, led humanitarian campaigns and — to the dismay of puritans — shed layer after layer of chaste Islamic covering.

In the early 1890s, Zainab Fawwaz, an Egyptian feminist, declared that there was nothing in Islamic law prohibiting women from ‘involvement in the occupations of men’. This in a country where only a few decades earlier efforts to found a school for midwifery had foundered on popular hostility and the school had had to be filled with Abyssinians bought from the Cairo slave market.

That Islam’s liberal moment came juddering to a halt in 1914 is a little-known tragedy. In the first decade of the 20th century, Iranian and Turkish democrats had launched revolutions establishing parliamentary systems that limited the powers of the ruler — a similar movement in favour of popular sovereignty in Egypt had been thwarted by the British occupation two decades earlier. But war laid waste to the region and the British and French chopped up much of the former Ottoman Empire into mandate-sized chunks. Egypt stayed under British supervision, while in Iran and Turkey the powers were only kept at bay by new regimes that westernised furiously along Roman lines (Mussolini was the model), not Jeffersonian ones.

One of the reasons why Islam’s liberal moment was never revived was its association with an avowedly liberal West that in fact behaved anything but liberally; this confusion of message and messenger fuelled the Muslim Brotherhood and subsequent Islamist movements, while defenders of a measured westernisation such as the secular-minded Iranian prime minister Mohammad Mossadegh were rewarded for their political independence with the hostility of the West. (In 1951 Mossadegh nationalised Iran’s British-run oil industry; the CIA and MI6 toppled him in a coup two years later.)

Now, amid the beastliness of Isis and its fellow travellers, and the tendency of a growing number of westerners to demonise not Islamism or the terrorists but Islam tout court, it seems vital to recall that hopeful century when the lands of Islam engaged lustily with modernity in the hope that something of it can be recaptured — as, indeed, it briefly looked as though it might during the Arab Spring. The alternative is to perpetuate the self-fulfilling consensus around which the Isis ideologues and our own populists unite: a story of inevitable conflict and alienation based on a historical fallacy.