In July 2011, a quiet European capital was shaken by a terrorist car bomb, followed by confused reports suggesting many deaths. When the first news of the murders came through, one small group of online commentators reacted immediately, even though the media had cautiously declined to identify the attackers. They knew at once what had happened – and who was to blame.

“This was inevitable,” explained one of the anonymous commenters. And it was just the beginning: “Only a matter of time before other European nations get a taste of their multicultural tolerance that they’ve been cooking for decades.”

“Europe has been infested with venomous parasitic vermin,” explained another. “Anything and everything is fine as long as they rape the natives and destroy the country, which they do,” said a third.

As the news grew worse, the group became more joyful and confident. The car bomb had been followed by reports of a mass shooting at a nearby camp for teenagers. One commenter was “almost crying of happiness” to be proved right about the dangers of Islam. “The massacre at the children’s camp,” another noted, “is a sickening reminder of just how evil and satanic the cult of Islam is.”

The myth of Eurabia: how a far-right conspiracy theory went mainstream – podcast Read more

A couple of hours after the first reports of the bomb explosion in central Oslo, a few doubts emerged to cloud the picture: “Because the targets in the shooting were all good little leftists, won’t the shooter be played up as a rightwing extremist, whatever his actual motives?” one person asked.

When information emerged to suggest that the attacker might be a “tall Nordic guy”, one of the commenters, who called himself “Fjordman”, realised the true nature of the disaster: “Judging from some of the recent information, it must be treated as a serious possibility that this is actually some Timothy McVeigh, not a Muslim. It is too early to tell. If that is indeed the case … it would practically destroy my country, and make the working conditions for people like myself incredibly difficult for a long time to come, I’m afraid.”

The truth turned out to be worse than Fjordman feared. The massacre in Oslo had not been committed by Muslims. It was the work of a white supremacist, Anders Behring Breivik, who had detonated a bomb in Oslo, killing eight people, and then shot dead 69 others, many of them teenagers, at a youth camp run by Norway’s Labour party. And, according to the manifesto he published online, Breivik had been directly inspired by Gates of Vienna – the blog where all these comments appeared on the day of his massacre. Breivik called the ideology that justified his murders “The Vienna school”, after the blog.

Fjordman, whose real name is Peder Are Nøstvold Jensen, now lives in obscurity in provincial Norway. He outed himself as the man behind the pseudonym to a Norwegian tabloid in the weeks following the massacre – but managed to avoid testifying at Breivik’s trial, thanks to the intervention of high-powered lawyers paid for by the Middle East Forum, a rightwing American group that would later sponsor Tommy Robinson – real name Stephen Yaxley-Lennon – in Britain. Nonetheless, Jensen’s influence on Breivik, however indirect, had been considerable.

Breivik borrowed part of the title of his manifesto, A European Declaration of Independence, from one of Fjordman’s blog posts, and many of the chapters in it were simply reprintings of Fjordman’s postings on various blogs, mostly Gates of Vienna, but also a far-right and passionately anti-EU site called the Brussels Journal.

Gates of Vienna was, and still is, run by Edward “Ned” May, an American computer programmer from Washington DC. It was among the first in a wave of blogs that urged the US to war after the shock of 9/11, and almost certainly the most fanatically anti-Muslim. It takes its name from the siege of Vienna in 1683, when an Ottoman Turkish army was defeated by a Polish-led one. Its essential thesis is that this was only one battle in a long war and that Europe and its civilisation are constantly threatened by a Muslim invasion.

On these varied online forums, the narrative was always the same: a liberal cabal was conspiring with hostile Muslim powers to hand over the decent working people to Islam. This was the animating myth of the bloggers, calling themselves the “counter-jihad”, who congregated at Gates of Vienna and other like-minded sites – and inspired both the violence of Breivik and the message of the racist far-right parties that have transformed European politics in the past decade.

But all of these later conspiracy theories took inspiration from a founding myth of contemporary Islamophobia: an invented plot, known as “Eurabia”, to destroy European civilisation. This is the doctrine that Jensen promoted and Breivik acted on, a hidden underpinning of a movement that has changed the world.

Once an ideology confined to the kookier corners of the internet, the idea of Eurabia is now visible in the everyday politics of the US, Australia and most of Europe: when Trump tweets about stabbings in London and falsely claims that crime in Germany is “way up”, he is invoking the Eurabian myth, taken as fact on Fox News, that European liberals have surrendered their cities to Muslim criminals.

The spread of the belief that elites conspired to push Muslim immigration on their native populations is also the story of a conspiracy theory that was nourished on some of the very first blogs and message boards, started appearing in mainstream discourse after 9/11, and then took on a life of its own, even while the supposed facts behind it were exposed as ridiculous. It is a lesson in the danger of half-truths, which are not only more powerful than truths but often more powerful than lies.

Eurabia is a term coined in the 70s that was resurfaced by Gisèle Littman, an Egyptian-born Jewish woman who fled Cairo for Britain after the Suez crisis, and then moved to Switzerland in 1960 with her English husband. She wrote under the name of Bat Ye’or (Hebrew for “Daughter of the Nile”). In a series of books, originally written in French and published from the 1990s onward, she developed a grand conspiracy theory in which the EU, led by French elites, implemented a secret plan to sell out Europe to the Muslims in exchange for oil.

The original villain of Littman’s story was General Charles de Gaulle. It is difficult for an outsider to understand how De Gaulle, who led the French resistance to the Nazis and was probably the greatest conservative statesman in French history, could be reinvented as the man who betrayed western civilisation for money. But Littman had lived many years in France, and the French far right hated De Gaulle, and indeed tried several times to assassinate him. Not only had De Gaulle fought the Vichy government, he had also admitted defeat in the long and hideously bloody war of Algerian independence – granting an Arab Muslim country its freedom at the expense of the French-Christian settler population, who had to retreat to France (and whose descendants formed the backbone of Jean-Marie Le Pen’s National Front).

Agreeing to Algerian independence was understood by the French far right as a betrayal. De Gaulle had been brought out of retirement and restored to power in 1958 because he was believed to be on the side of the settlers in their war, which was opposed by much of the left. And so, to the far right, the Mediterranean came to seem like the frontline in a long, shifting struggle between rival colonialisms, Christian and Muslim, in which the Muslims had won a great victory in Algeria. Where would their new advance stop?

Littman’s argument, framed by her experience in Egypt (which a French force had invaded, along with the British and Israelis, in 1956), was that Islam imposed a second-class status on all non-Muslims, whom they ruled. This status of “dhimmitude” – a coinage of Littman’s, meaning subjection to Islamic rule on pain of “forced conversion, slavery or death” – was now to be extended to Europe.

According to Littman, her books describe “Europe’s evolution from a Judeo-Christian civilisation, with important post-Enlightenment secular elements, into a post-Judeo-Christian civilisation that is subservient to the ideology of jihad and the Islamic powers that propagate it.”

She saw tentacles of the great conspiracy in committees of blameless tedium and obscurity, such as the Euro-Arab Dialogue, an institution set up by the European Economic Community and the Arab League in the 70s to promote greater discussion between the regions. Her conspiracy theory was dismissed in 2006 by the Israeli historian Robert Wistrich as “the protocols of the elders of Brussels”, but what mattered more was the place he chose to challenge her ideas: a conference in Jerusalem on antisemitism to which she had been invited despite her lack of academic status. September 11 had changed everything for Littman, she told Haaretz after the conference: “In the United States, I am certain that the September 11 attacks woke people up, including the Jewish community that had previously ignored me, because it belongs more to the left.”

She explained to Haaretz the future she saw for Europe. “We are now heading towards a total change in Europe, which will be more and more Islamicised and will become a political satellite of the Arab and Muslim world.”

This was the idea that the Norwegian Jensen was enchanted by, and which, as Fjordman, he transmitted to Anders Breivik.

Facebook Twitter Pinterest Marine Le Pen, president of France’s far-right National Rally (formerly National Front) party, applauds the former US presidential adviser Steve Bannon (left) after his speech at the party’s annual congress in March 2018. Photograph: Philippe Huguen/AFP/Getty Images

Jensen is unusual among Eurabia believers in that he has actually had some experience of the Muslim world and even speaks Arabic. He is the son of a socialist politician in Norway and studied Arabic in Cairo – his earlier university studies in Bergen had included English (which he writes fluently), Russian, Arabic and Middle Eastern history. In 2000, he had been interviewed by the local paper back in Norway, and spoke enthusiastically about his hosts in Egypt: “Outside the tourist areas, you meet friendly, hospitable, curious and open people who want to get to know you. I have been part of their daily lives. We’ve been invited to their homes, and talked and smoked shisha together.”

That was Jensen’s first encounter with Islam, and he was still in Cairo at the time of the 9/11 attacks. He says he saw then that there were some Muslims who celebrated the slaughter, and he also saw that this wasn’t reported in the Norwegian papers. The next year, he worked for the Norwegian Refugee Council in the disputed city of Hebron in the occupied West Bank. Unusually among Scandinavians who have worked with Palestinians in Israel, he identified with the Israelis. He narrowly escaped a suicide bombing in Tel Aviv, at a bar where two of his colleagues had been killed in another attack the previous year. The experience cemented his growing fear and loathing of Islam.

The fact that the Norwegian press took a generally pro-Palestinian line while he and his friends had been the victims of Palestinian terrorism helped to convince Jensen that Islam was an existential threat to European civilisation which the politically correct establishment was wilfully ignoring. Like Littman, he seems not to acknowledge any element of nationalism in Palestinian consciousness: it is all either Arab or Muslim. In fact, the belief that Islam is hostile to national consciousness is quite widely held on the right: the philosopher Roger Scruton brought it up in a controversial speech on nationality in Hungary in 2013, in which he contrasted European Christian nations with Islamic empires.

In 2003, Jensen returned to Norway, where he attempted to make a name for himself as a public intellectual. At first, he was hostile to feminism, accusing feminists of destroying Norwegian manhood. But the focus of his concerns soon switched to Islam. He started writing under the pseudonym “Norwegian Kafir” on an American blog called Little Green Footballs, which loudly and fervently supported the invasion of Iraq. From then on, his writing appeared in English, on American-hosted blogs. There, he hammered into shape the narrative of elites, specially identified with the EU, who are destroying and betraying Europe by the deliberate encouragement of mass immigration.

At this point in time, the Eurabian conspiracy appealed largely to those who had long perceived a conflict between Islam and the Judeo-Christian west – with Israel as a beleaguered and persecuted outpost of western values. These people, largely on the American right, were among the earliest exponents of Eurabia – but as they never ceased to complain, theirs was not an attitude very widely shared in Europe. What would soon supply the emotional force of the fantasy was another set of ideas about global migration, less conspiratorial in their essence, but much more widely accepted among generally apolitical Europeans. These, also, originated in France, where they were known as the “great replacement”.

The idea of the great replacement had its origin in a blatantly racist French novel of the 1970s, The Camp of the Saints, in which France is overthrown by an unarmed invasion of starving, sex-crazed Indian refugees when the French army is not prepared to fire on them. The moral of the book is that western civilisation can only be saved by a willingness to slaughter poor brown people. Steve Bannon, among the founders of the rightwing news site Breitbart and a former adviser to President Trump, has referred to it repeatedly.

Throughout the 80s and 90s, the naked racism of The Camp of the Saints kept it largely out of public debate. But the rise of Islam as a global force allowed the question to be recast. If the threatening masses were defined by religion rather than by skin colour, then hating them could be presented as an intellectual commitment rather than a racist one.

And the paranoid did have a large, shadowy half-truth to fall back on. The demographic shrinkage facing Europe is real and undeniable, and it was obvious in the early years of this century, too. So are the much greater birth rates in sub-Saharan Africa and south Asia. In 2002, Russia and Pakistan both had populations of about 145 million; by 2017, Russia’s population was 144 million while Pakistan’s was 200 million.

The next stage in the development of a xenophobic populist worldview was for the two narratives to merge, so that Islam and Muslims became both a conspiracy and a demographic threat.

The 9/11 attacks changed attitudes to Islam in much of Europe and the US. Israel and the US now shared a sense of being under attack from Muslims. Without 9/11, Littman would have remained an obscure crank, and Jensen more obscure still. But the assault on the twin towers unleashed an immense backlash of wounded American pride and nationalism that led to the devastation of two whole countries, Afghanistan and Iraq, and countless deaths. It also fuelled a demand for explanations. Theories about the unique malevolence and danger of Islam answered a popular hunger. George W Bush declared at the time that the US had no quarrel with Islam, but many of his compatriots disagreed.

One of the many bad fruits of 9/11 was the new atheist movement, a phenomenon marked by mutual self-praise and undeviating hostility to Islam. Even if the ostensible target of much of the hostility was Christianity, the new atheists tend to consider Islam far worse and more “religious” a religion. The American writer Sam Harris’s breakthrough book The End of Faith from 2004 now reads like Bat Ye’or without the inconvenient scaffolding of easily disproved facts. “We are at war with Islam,” he writes. “It may not serve our immediate foreign policy objectives for our political leaders to openly acknowledge this fact, but it is unambiguously so. It is not merely that we are at war with an otherwise peaceful religion that has been ‘hijacked’ by extremists … Armed conflict ‘in the defence of Islam’ is a religious obligation for every Muslim man ... Islam, more than any religion humans have ever devised, has the makings of a thoroughgoing cult of death.”

In the run-up to the Iraq war, and after the invasion, coverage in American newspapers and on television was, to a European eye, jingoistic in the extreme. The possibility of defeat was unthinkable. Nonetheless, a new wave of bloggers began using the term “MSM” for “mainstream media” as a disparaging reference to the large media organisations’ pretended neutrality. One of the earliest and most influential of these was Little Green Footballs, founded and run by Charles Johnson, a Los Angeles-based former session guitarist with an interest in web design. It was typical of the moment that he was an opinionated amateur with no credentials, whose real advantage was that he could build websites at a time when this required some programming skill.

Get the Guardian’s award-winning long reads sent direct to you every Saturday morning

Jensen, commenting on Little Green Footballs as Norwegian Kafir, made it a distribution point for Eurabian ideas. Another was Gates of Vienna itself, run by Ned May under the moniker Baron Bodissey after a sage in the sci-fi novels of Jack Vance. Then there was Jihad Watch, run by the American author Robert Spencer. Both Spencer and his frequent collaborator Pam Geller were banned from the UK in 2013 for making statements likely to foster hatred and violence between communities.

The only European blog of note in this constellation was the fanatically anti-EU site the Brussels Journal, where the Conservative MEP Daniel Hannan was a contributor. The Brussels Journal was run by Paul Beliën, a far-right Belgian journalist and author. Jensen was active on all these sites, taking part in discussions in which the Eurabian beliefs gave rise to something that called itself the counter-jihad movement.

Nowadays, when Facebook effortlessly spreads disinformation around the world, it is difficult to recapture the sense of revelation, and of belonging, that once accompanied the discovery of a new blog. The cramped but, to its adherents, strangely comforting thought world of the counter-jihad blogs turned politics into a gigantic online game. Anyone could play and everyone could find in it their inner child: “Some people think I’m weird; some think I am exceptionally intelligent,” Jensen had told a reporter when he was still a student in Cairo.

The boundaries between these blogs and the “MSM” they affected to despise were porous. Some writers aimed for a high-minded tone about the dangers of Muslim immigration: the former Financial Times columnist Christopher Caldwell published in 2009 a book, Reflections on a Revolution in Europe, that recapitulates the idea of a slow-moving Muslim barbarian invasion from a position of Olympian disdain: “Immigrants also bring a lot of disorder, penury and crime … Muslim culture is unusually full of messages laying out the practical advantages of procreation … If you walk north across the Piazza Della Repubblica in Turin, you see, mutatis mutandis, what the Romans saw. To the east, two well-preserved Roman towers remain, and so do the walls built to separate citizens from barbarians. Today, in the space of about 60 seconds on foot, you pass from chic shops and wine bars through a lively multiethnic market into one of Europe’s more menacing north African slums.”

Some were less highbrow. In 2004, the Daily Telegraph gave a column to the Canadian prophet of American greatness Mark Steyn, who had originally made his name as a witty critic of musical theatre. Doom and horror was all he saw in Europe’s future. As early as 2002, he said: “I find it easier to be optimistic about the futures of Iraq and Pakistan than, say, Holland or Denmark” – a remark he was still proudly quoting for Telegraph readers in 2005, when Iraq had become a slaughterhouse.

In terms that anticipated Jensen, Breivik and the alleged manifesto of the man charged with the Christchurch massacre, Steyn wrote (and the Telegraph published) this prophecy: “In a democratic age, you can’t buck demography – except through civil war. The Yugoslavs figured that out. In the 30 years before the meltdown, Bosnian Serbs had declined from 43% to 31% of the population, while Bosnian Muslims had increased from 26% to 44%.”

Facebook Twitter Pinterest ‘Europeans, vote for AfD, so that Europe will never become ‘Eurabia’!’ reads a campaign poster in Berlin for the far-right party during this year’s European elections. Photograph: Clemens Bilan/EPA

Compare Steyn in 2005 with the manifesto of Patrick Crusius, who confessed to murdering 22 people in El Paso earlier this month: “This attack is a response to the Hispanic invasion of Texas. They are the instigators, not me. I am simply defending my country from cultural and ethnic replacement brought on by an invasion ... America is rotting from the inside out, and peaceful means to stop this seem to be nearly impossible.”

In 2007, the believers in a counter-jihad began to meet up in the real world. After a preliminary meeting of bloggers, commentators and Danish and Norwegian sympathisers in Copenhagen, attended by Jensen, a conference was arranged by May and the far-right Flemish party Vlaams Belang, in Brussels in 2007. This brought together most of the ideologues of Eurabia, as they attempted to transform it from an idea into a movement. Littman was the keynote speaker. Others present were Geller and Robert Spencer from the US, and Gerard Batten, later briefly the leader of Ukip in Britain. Ted Ekeroth, of the nationalist, rightwing Sweden Democrats, also attended.

As both Ukip and the Sweden Democrats rose to become powerful political forces, anxieties about terrorism were subsumed into much wider anxieties about demography, and about status within the old order. The American anthropologist Scott Atran has carried out extensive research into the mindset of the young men who become Islamic terrorists: the combination of wounded pride with the delight of belonging to a movement which has both global, apocalyptic significance and a living presence in a friendship group is tremendously important in recruiting jihadis. The same dynamic operates among their enemies: Breivik was remarkable chiefly in that he was so solipsistic that he could radicalise himself without the aid of any friends in real life, only those he imagined on the internet. He had at one stage approached his intellectual idol, Jensen, via email, who brushed him off as “boring as a vacuum cleaner salesman”.

You do not have to be a jihadi to feel the tug of these compulsions. The counter-jihadis, just as much as their enemies, believed they were entering an apocalyptic battle between good and evil. This is a century of wounded pride and anxieties about status for almost everyone.

Despite all this, there were some signs, even before the Breivik killings, that the original Eurabian front would break up. Those who were opposed to immigrants in general began to separate from those who hated Muslims in particular. Johnson, the founder of Little Green Footballs, excommunicated most of his followers in 2010 because of their increasing closeness to parties of western Europe that he regarded as being descended from fascists – the Vlaams Belang in Belgium and the Sweden Democrats, although he also denounced the English Defence League. Johnson was a genuine philosemite, who could not forgive the taint of antisemitism.

The anti-immigrant right had good reasons for separating itself from the anti-Muslim right. If the logic of the “Vienna school” – Jensen, Spencer and Geller, May and Littman – led inexorably to civil war and the righteous slaughter of Muslims and their leftie enablers, then most of the right shrank back from it. Commenters such as Douglas Murray and Caldwell quite genuinely believed that Breivik was insane, and that his actions had no relation to the ideas that he espoused. There may in this have been an element of self-deception, but it is also a testimony to the sort of instinctive, unthinking decency we all need sometimes to rescue us from the consequences of our ideas. It seemed that some kind of pragmatism would prevail.

The hope now seems deceptive. What changed this was above all the election of the US president, Donald Trump, whose then adviser Bannon was a believer in a “brutal, bloody ... global war” against “Islamic fascism”. They showed that there was a huge constituency for racialised hatred and despair and – for them – no real negative consequences, electoral or otherwise, in pandering to it.

Since Breivik’s massacre, his own beliefs have only become more widespread. They have spread into the politics of all European countries. In the campaign for the European elections this May, the German far-right party AfD ran posters showing a naked white woman being pawed by dark-skinned men in Arab headgear. One had stuck his fingers in her unresisting mouth. “Europeans, vote for AfD, so that Europe will never become ‘Eurabia’,” said the caption. Millions of people who have never heard of Bat Ye’or, of Fjordman, or even of Breivik and Bannon, now understand that poster at a glance, and no amount of evidence will shake their certainty. They now believe all politics comes down to the words of one of Trump’s more recent tweets: “The losers all want what you have, don’t give it to them … Be strong & prosper, be weak & die!”

But who, in this situation, are the losers, and who are the strong? Last week, in an apparent attempt to emulate Breivik, a rich, disaffected young Norwegian, Philip Manshaus, shot his way through the entrance gates to a mosque in the upmarket suburb of Oslo where he lived and started firing at the congregation. He was wrestled to the ground by an unarmed 65-year-old Muslim, Mohammed Rafiq, who then held him down, with the help of another man, until the police arrived. On the Gates of Vienna blog, this episode was not deemed worthy of mention. Instead, its devoted readers were told that Muslims had been responsible for a recent outbreak of animal cruelty in Sweden.

•Follow the Long Read on Twitter at @gdnlongread, and sign up to the long read weekly email here.