Imagine it. A network of violent radicals is picking off the world's leaders one by one. They have killed the American President, the Russian head of state, the French President, the Austrian head of state, and the Spanish Prime Minister.

Bomb attacks are ripping through the world's richest cities: explosions devastate Wall Street, the London Underground, a theatre in Barcelona, cafés in Paris, parades in Moscow. The police profile of a typical bomber warns: "He walks to his death with courage and no regrets." There is panic, and governments launch programmes of torture and deportation targeted at immigrant communities. Yet still the radicals wash defiantly across the world, killing as they go. They say they have "only one aim, one science: destruction".

It sounds like a feverish novel about al-Qa'ida, set 30 years from now. But it has already happened. It is a story from our past. In the late 19th and early 20th century, anarchist bombers did all this. They were prepared to die for their beliefs. They lived in the same places as today's Islamists – such as Whitechapel, in east London – and they struck the same targets, like lower Manhattan on a clear September morning.

Download the new Independent Premium app Sharing the full story, not just the headlines

In a new documentary – The Enemy Within, by Joe Bullman – young Islamists read the words of yesterday's Jewish anarchists, from their writings and trial transcripts. While the societies they dream of building after the bombs are very different, their rage, their alienation, and their tactics are almost identical. The words fit so easily into their mouths that the Islamists say it is "creepy".

Mark Twain said: "History doesn't repeat itself, but it does rhyme." Are there lessons buried in this ripple of rage spreading across a century? For decades, anarchist radicals seemed like an ineradicable force that would bleed Western societies forever. Within a generation, they were gone. So can the anarchists show us what makes young men attack their own societies – and what makes them stop? Can it tell us what tactics defeat an amorphous underground movement, and what only makes them stronger? From the nitroglycerine of the 19th century, is there a fuse that ends with the jihadists of 2009?

I. Terminus

As the sun set on 12 February 1894, the Café Terminus at the Gare Saint-Lazare was full of young Parisians listening to an orchestra when the music stopped abruptly. A fireball consumed everything in sight: the world went black. When the survivors came round, there was a jigsaw of body parts around them, and people on fire, running, screaming. It was the work of a smartly dressed 20-year-old French accountant called Emile Henry. He had placed a bomb in a metal workman's lunchbox and hurled it at the orchestra. This wasn't his first attack: a few months before, he had blown up a police station, killing five people, and returned calmly to his desk, where he finished the ledgers he had been working on.

But it was the first time a private individual had randomly blown up civilians. As the historian Dr John Merriman, who teaches at Yale University, says: "It was the day that ordinary people became the targets of terrorists." But Emile Henry was not an anarchist from Central Casting. He was an intellectual born into the French bourgeoisie, living in part off handouts from his rich aunt. He was – by all accounts – a sensitive person who had spent his life appalled at the cruelty all around him. He claimed his act would save lives in the end: that he was murdering out of compassion.

Henry was living in a Paris of vertiginous inequalities. In a quarter of an hour you could walk from the palatial glamour of the opera house to slums where babies were routinely dying of tuberculosis. The divide ran right though his soul: he had the education of the rich, but he had slumped down into the tubercular slums.

Emile's father, Fortune Henry, had run away from his middle-class family in 1848 at the age of 16 to join the revolution in Paris. When Parisians seized control of their own city in 1871 and ran it as a democratic commune, Fortune manned the barricades and rallied the crowds. But when the French state recaptured Paris – massacring 25,000 people as it went – he was condemned to death, and fled to Spain. Emile Henry was born there, and he was raised on tales of how the French state had brutally suppressed freedom. The boy grew to see all governments as evil, especially when the Spanish authorities confiscated the family's belongings to punish their anarchist sympathies. His father was forced to work in filthy factories where he contracted mercury poisoning. He died when his son was 10.

Henry's mother begged for cash from her wealthy relatives, who helped send Henry to the best schools in Paris. He was an exceptionally successful student, and for a time – as a pale, tall young man, with a reddish beard – he became an engineer. But, on a meagre trainee engineer's salary, he was still stuck in the poorer arrondisements of Paris, where he was stunned by the waste of life all around him. The poor majority had no political voice, and scarcely enough food to live: a quarter of all children died before reaching adulthood.

Daily coronavirus briefing No hype, just the advice and analysis you need Enter your email address Continue Continue Please enter an email address Email address is invalid Fill out this field Email address is invalid Email already exists. Log in to update your newsletter preferences Register with your social account or click here to log in I would like to receive morning headlines Monday - Friday plus breaking news alerts by email Update newsletter preferences

"I would like simply to disappear, to annihilate myself, in order to escape the perpetual anguish that strangles and breaks heart and soul," he wrote. He concluded that wealthy Paris was dominated by "frauds", and "only the cynics and grovellers can get a place at the banquet ... [The rich have] appropriated everything, robbing the other class not just of the sustenance of the body but also the sustenance of the mind."

Across Europe, the nation-state was asserting its power over ordinary citizens in a deeper and harsher way than ever before, with governments seizing taxes and young men for conscription at an unprecedented rate. In response, there was a growing anarchist movement that simply said that the state was illegitimate, and should be disbanded.

The term "anarchist" had originally been an insult, but, in 1840, a French provincial printer's assistant called Pierre-Joseph Proudhon picked it up and wore it with pride. He said if governments were disbanded, people would organise themselves into peaceful democratic communes that would run their own affairs, without police or laws or taxes. It was the state – with its apparatus of coercion and violence – that made people bad. Remove the state, and you would have a natural order at last, based on personal freedom. Law is tyranny; property is theft.

In a society where the emaciated poor were routinely being worked to death, it was an appealing message. As he lay dying because he had been made to work in toxic factories since childhood, a porcelain worker known to history only as "M L" wrote: "Accursed society, you are responsible for my illness. Thoughtless and cynical bourgeois, do you not sense that I can transform myself into someone who can right wrongs, an avenger of the innumerable existences that your society has massacred, an avenger of all those who have revolted and live as outlaws, and those who have been tortured or eliminated? Bourgeois ... I want to talk with me at least some of those who are responsible for my death."

To Emile Henry, it seemed persuasive. He took money from his bourgeois aunt – and wrote cordial letters of thanks – but cursed the bourgeoisie as "evil". When he was ordered to attend the military lottery, where he could have been conscripted, he went on the run. At lectures across the city, he heard the argument put by anarchists that the only way to put their philosophy into practice was by "the propaganda of the deed". Acts of violence against the state or the populace would show the state's power was illusory and stir a general revolt. Just as most Muslims reject jihadism today, most anarchists rejected violence against civilians, calling it "common murder". But developments in France made Henry more determined to side with the furious fringe of anarchism: striking miners were crushed by troops, and the rich became richer. He wrote: "The entire bourgeoisie lives from the exploitation of the unfortunate, and all of it should pay for its crimes."

He was captured at the scene of the bombing. He said he had one regret: that he didn't kill more "bourgeois". If only he had a bomb big enough, he boasted, he would have blown up the whole of Paris. Only from the rubble could a just society emerge. In a letter to his mother, he said: "You must not believe those who will say that your son is a criminal. The real criminals are those who make life impossible for anyone with a heart, those men who uphold a society in which everyone suffers."

After Henry was executed at the age of 21, a series of revenge bombings staged by anarchists ripped through France. One of the killers, Auguste Vaillant, declared: "We will spare neither women nor children because the women and children we love have not been spared. Are they not innocent victims, these children, who in the faubourgs slowly die of anaemia, because bread is rare at home? Those women who in your workshops suffer exhaustion and are worn out in order to earn 40 cents a day? These old men whom you have turned into machines so that they can produce their entire lives and whom you throw out on to the street when they have been completely depleted? You will add other names to the bloody lists of our dead ... but what you can never destroy is anarchy. Its roots are too deep, born in a poisonous society that is falling apart. It is everywhere, which makes anarchy elusive. It will finish by killing you."

II. All-American Anarchism

Emile Henry was only one member of a scattered freelance army who believed they could end the idea of government itself, and usher in an era of perfect freedom. Their attacks were made possible by the coincidence of two historical developments: the development of anarchist philosophy, and the invention of dynamite. In 1866, the Swedish industrialist Alfred Nobel invented this easy-to-carry, easy-to-make explosive, and it spread through the world's mining and construction industries like a rapidly fizzing fuse. But it took a tiny, malformed German anarchist to see how it could change the world's politics.

Johann Most was a 5ft-tall bookbinder filled with rage. As a child, an operation on his jaw had gone wrong, leaving it painfully jutting forward. His attempts to hide it under a huge red beard only attracted more attention. Most turned his humiliation outwards on to just causes – at least at first. He too ran away to Paris, and was immediately jailed after the crushing of the Commune, for demanding the vote for everyone. He argued for socialism, to be brought about through parliamentary democracy – and when he was released from jail he was elected to the German Reichstag on precisely this platform. But Otto von Bismarck launched a purge of all leftists, and Most had to flee again.

The purge crushed Most's belief in gradual reform. He became convinced the system could only be changed by blowing it up – and suddenly realised that explosives were now lying all over Europe and the US, in sheds controlled by ordinary workers. Dynamite needed no expertise to operate; it could be carried in your pocket; and it could kill. He announced: "It is within the power of dynamite to destroy the capitalist regime just as it had been within the power of gunpowder and the rifle to wipe feudalism from the face of the earth. A girdle of dynamite encircles the world!"

Most travelled from country to country, urging workers to pick up their dynamite and use it against the bosses who forced them to work 12-hour days, seven days a week, for starvation wages. He became the model for Ossipon, the refugee-anarchist Ossipon in Joseph Conrad's novel The Secret Agent, who walks the street with a bomb forever strapped to him, ready to blow himself up the moment the police swoop. In anticipation of Islamism, Ossipon brags that his enemies "depend on life ... whereas I depend on death, which knows no restraint and cannot be attacked. My superiority is evident."

Although it has been consigned to the memory-hole, one of the places where Most found the most recruits was the US. He washed up in the 1880s in a continent where 35,000 American workers died every year in industrial accidents. Whenever they went on strike for better conditions, they were savagely beaten by the police. The richest 2 per cent owned 60 per cent of the wealth, and the politicians and police did their bidding.

One of his most fervent disciples was a hard-drinking cowboy from Utah, never seen without a stetson and a strut. He was called "Big Bill" Haywood. He spent his childhood moving from one mining town to another, and had his eye slashed out in a mechanical accident when he was nine. By the age of 15, he spent almost all his time hacking at rock underground, where he saw men routinely get crushed or blasted. Writing about one typical town, he explained: "The people of this mining camp breathed copper, ate copper, wore copper, and were thoroughly saturated with copper ... Many of the miners were suffering from rankling copper sores, caused by the poisonous water. Human life was the cheapest by-product of this great copper camp."

Big Bill turned to anarchism after witnessing systematic state violence against ordinary people. When he organised a strike, US soldiers rounded up 1,000 miners at random and placed them in a barbed-wire bull-pen. They were detained there for seven months. As the police officer in charge declared, "To hell with the constitution!" They called it the "American Bastille."

Class war didn't seem like a metaphor to him: it was the reality of everyday life. The industrialist Jay Gould openly bragged: "I can hire one half of the working class to kill the other half." So Haywood – some historians believe – blew up the governor of Idaho, Frank Steunenberg, in 1907, and his trial was the biggest news story of the year. His lawyer, the legendary Clarence Darrow, urged the jury to side not with "the spiders of Wall Street" but with "the men who toil with their hands ... through our mills and factories, and deep underneath the earth. I am here to say that in a great cause these labour organisations have stood for the weak, they have stood for every humane law that was ever placed on the statute books. I don't care how many wrongs they have committed – I don't care how many crimes – I just know their cause is just."

It is a sign of how widespread the sympathy for anarchists was that Haywood was acquitted, and became an American folk hero. He eventually had to flee the US during the First World War when he urged people to resist the draft, and was sentenced to 20 years in jail. He fled to the Soviet Union, found it to be "hell", and drank himself to death.

This is only one small slice of a larger story unfolding in every developed country. Anarchist attacks on politicians were remarkably successful, starting when three young men hurled bombs into a carriage carrying Tsar Alexander II in 1881, killing him and several members of the crowd. Anarchists claimed their heftiest scalp when, in 1901, a young militant called Frank Czolgosz waited in line to shake US President McKinley's hand in Buffalo – and shot him in the gut. (This act gave us President Theodore Roosevelt, one of the most aggressively imperialist and racist presidents in US history). But gradually the anarchist fervour boiled down further and further into attacks on ordinary civilians – which is why they still echo into our world today.

III. "It was written 100 years ago, but it is happening today"

Does this anarchism bear any relationship to the jihadists who bomb the very same targets today? When the film-maker Joe Bullman got young British Muslims with some sympathy for the 7/7 bombers to read the words of anarchists put on trial at the Old Bailey a century ago, they showed an exhilarated recognition. Adam Munevar Khan says: "It was written 100 years ago, but it is happening today – to the Muslims." Mohammed Rahmen says: "Anarchism has been represented to be a doctrine of insanity and murder – its principles, its ideals, they've been unmentioned, lied about. That really penetrated my way of thinking. That's exactly how Islam is."

The Islamists read the anarchist lines to camera with feeling. One of them says: "We are met by the cry of assassins, dynamiters, fiends – but let's see who utters these cries. It's the same people who daily massacre more people than the anarchists of all countries have ever killed." It could be Mohammad Sidique Khan, the 7/7 murderer, announcing: "Your democratically elected governments continuously perpetuate atrocities against my people all over the world. And your support of them makes you directly responsible, just as I am directly responsible for protecting and avenging my Muslim brothers and sisters. Until we feel security, you will be our targets. And until you stop the bombing, gassing, imprisonment and torture of my people, we will not stop this fight."

Yet it's easier, at first glance, to see the differences between the two ideologies. Anarchists loathed religion, seeing it as another form of tyranny to be destroyed; Islamists want their severe interpretation of religion to be obeyed by everyone. Anarchists were some of the first to fight for feminism and sexual freedom; Islamists want to imprison women in burqas and in their homes, and to kill gays. Anarchists demanded absolute free speech; Islamists chant "death to free speech". Anarchists loathed racism; Islamists are frequently racist against Jews. Anarchists wanted a society of absolute freedom; Islamists want a society of absolute obedience.

But neither had a very clear picture of what the world would look like after the smoke from their bombs had cleared. Their visions of the future were vague: both no-state and the caliphate were hazy hope-dreams. Below and beneath them, there were deep structural similarities.

Both groups believed their violence was justified by the larger illegitimate state violence they witnessed as young men. For the anarchists, it was the crushing of the Paris Commune and the executions of innocent anarchists after the Haymarket bomb of 1886 in Chicago; for the Islamists it is the assaults on the Palestinians, on Afghanistan, and on Iraq. However warped, they believe they are killing out of compassion for the victims of these crimes. The anarchist Emma Goldman wrote: "To those who say hate does not give birth to love, I reply that it is love, human love, that often engenders hate."

They justified their attacks to themselves by claiming they were trying to give the wealthy, or the West, a taste of how "their people" felt. Yet in both movements, intriguingly, it was largely middle class intellectuals who turned to violence. Both Emile Henry and Mohammed Atta – the leader of the 9/11 hijackings – were engineers who found in mathematics a sense of purity and order and rationality that soothed them, and seemed like a refuge from a chaotic world. The leading anarchists in Europe – Mikhail Bakunin and Peter Kropotkin – were both Russian noblemen, just as Osama bin Laden is the son of a Saudi billionaire. (Bakunin and Kropotkin, however, strongly opposed targeting civilians.) They were people who chose to renounce their riches and side with the embattled tribe "beneath" them, and claimed to be fighting for its survival.

Both waves of violence were reactions to tectonic shifts in how power worked in the world. Anarchist attacks were a violent reaction to the rise of the nation-state; Islamist attacks within the West are to a significant degree a violent kick-back against Western states asserting their power abroad. These reactions were only made possible by new networks of communication. For the anarchists, the revolution in shipping and telegrams made movement across continents suddenly faster and freer than ever: a genuinely international network moving rapidly between countries could develop for the first time. For Islamists, the internet made the movement of ideas and plans instantaneous: a global movement simultaneously operating in Tora Bora and Manhattan was suddenly possible.

And for this reason, both movements produced vicious backlashes against immigrants that went far beyond the people who actually carried out the attacks. In Bullman's film, he gets contemporary asylum-bashing pundits like Gary Bushell and Nick Ferrari to read the rage directed at Jews in Britain after a small number of Jewish immigrants became anarchists and launched bombings. Ferrari reads a Daily Mail column from 1911 that barks: "There are hundreds of anarchists in Whitechapel ... but there's no way of learning anything about them. In this great foreign city east of Aldgate the English policeman is an uncomprehending foreigner ... We can't continue to let the scum of Europe [come here]."

And this perhaps points to the most important echo of all. When governments reacted to these attacks, at first they charged angrily down a path that made anarchism worse – and guaranteed more of their citizens would die.

IV. Why did the attacks stop?

The postscript to anarchist bombings in almost every country was a bonfire of civil liberties. After Wall Street was blasted with a massive bomb in 16 September 1920, killing 38 people including a 16-year-old newspaper delivery boy, the US government launched a huge indiscriminate programme of deportations of "radicals" – often peaceful left-wingers. It was masterminded by a young man called J Edgar Hoover, who learned then the tactics of indiscriminate smearing he was to use throughout the cold war. For the first time in the country's history, Congress declared an idea to be "un-American", and said anybody preaching anarchism – however peacefully – would be held responsible for "aiding" the attacks. There was a raft of convictions of people who had done nothing except discuss anarchism and suggest there was some justice in its analysis.

There was a smattering of small countervailing voices in America, but in the initial hysteria, they were drowned out. The federal judge George W Anderson said the Justice Department was engaging in "utterly illegal acts, committed by those charged with the highest duty of enforcing the laws." The US Attorney Francis Fisher Kane resigned, warning that "the policy of raids against large numbers of individuals is generally unwise and very apt to result in injustice".

A presidential commission warned that this crackdown only made the anarchist warnings about a police state seem prescient. To the young men teetering on an act of violence, torture and police brutality made the anarchists sound right – and violent resistance necessary. The commission said the structural causes of the violence had to be dealt with instead, explaining: "The crux of the question is – have the workers received their share of the enormous increase in wealth which has taken place in this country? The answer is emphatically – no ... Throughout history where a people or a group has been arbitrarily denied rights, reaction has been inevitable. Violence is a natural form of protest against injustice."

But nobody wanted to hear these arguments. The public and the politicians wanted vengeance. Some governments, like France's, exploited the attacks to shut down all left-wing protest. Hoover employed a raft of agents to find a bogus "Russian connection" to the Wall Street bombing, to justify aggression against the Soviet Union.

Eventually, the American people returned to their senses, and chose a president who saw the threat in a cooler way. President Warren Harding said: "It is quite true that there are enemies of the government within our borders. However, I believe their number has been greatly magnified."

But the countries that had the harshest crackdowns ended up with the largest anarchist movements of all, while those that reacted calmly and kept their freedoms open saw the movements implode much faster. Professor John Merriman – whose book The Dynamite Club is one of the best accounts of the anarchist attacks – explains: "After the Italian king Umberto I was assassinated by the anarchist Gaetano Bresci, the Italian state response was deliberately restrained and minor. This undercut the movement. By contrast, Spain reacted at the same time with a programme of brutal repression and torture. They ended up with the biggest anarchist movement in Europe. Then later, when they stopped torturing people, the anarchist attacks stopped. I'm not an expert on contemporary terrorism, but the lesson for us seems pretty clear."

From the 1920s on, the anarchist attacks began to dwindle, and by the late 1930s they were over. Why? What happened? Nobody is entirely sure – but most historians suggest a few factors. After the initial wave of state repression, civil liberties slowly advanced – undermining the anarchist claims. The indiscriminate attacks on ordinary civilians discredited anarchism in the eyes of the wider public: after a young man blew himself up in Greenwich Park in 1892, his coffin was stoned and attacked by working class people in the East End. The anarchists' own cruelty and excess slowly deprived them of recruits.

But, just as importantly, many of the anarchist grievances were addressed by steady reforms. Trade unions were finally legalised, and many of their demands were achieved one by one: an eight-hour working day, greater safety protections, compensation for the injured. Work was no longer so barbaric – so the violent rejection of it faded away. The changes were nowhere near as radical as those demanded by the anarchists, but it stripped them of followers step-by-step.

Could the same be done with Islamism? The lesson from the death of violent anarchism is that the solution lies beyond blanket violent repression of them or its polar opposite, capitulation to their demands. The answer is gradual reform that ends some – but not all – of the sources of their rage. Clearly, many of Islamists' "grievances" should be left unaddressed: we must never restrict the rights of women or gay people or end the freedom to discuss religion openly, as they demand. But there is plenty we can do.

When the huge violence directed at workers and the poor stopped, violent anarchist attacks stopped. An end to the extensive violence directed towards many Muslims could have a similar effect. It would require significant changes here at home. We would have to kick our addiction to oil, so we will no longer be drawn into hellish oil-grabs into Muslim countries, or into holding hands with murderous tyrannies like the House of Saud. We will have unequivocally to renounce torture (even when it is practised by "allies" such as the Egyptian dictatorship), and press for peace for the Palestinians instead of arming and funding the assault on them. This will never be enough for the jihadists, of course – but if we do it, they will find their base of furious young men dissolving beneath their feet.

The ghosts of Emile Henry and Johann Most and Big Bill Haywood are standing before us, with their sticks of dynamite slowly fizzing. Are we going to make the same mistake that our governments did when dealing with them – or, after a century, have we learned how to put out the fire this time?

'The Enemy Within' in on Channel Four tonight at 8pm

You can follow Johann on twitter at http://twitter.com/johannhari101

If you're interested in the anarchist movements discussed here, two excellent books to check out are 'The Dynamite Club' by John Merriman, or 'The Day Wall Street Exploded' by Beverley Gage.

If you're interested in anarchist philosophy more generally, check out Peter Marshall's book 'Demanding the Impossible', which is an excellent history of the idea.