The shooter is almost always male. Of the past 129 mass shootings in the United States, all but three have been men. The shooter is socially alienated, and he can’t get laid. Every time you scratch the surface of the latest mass killing, in a movie theatre, a school, the streets of Paris or an abortion clinic, you find the weaponised loser. From Jihadi John of ISIS to Dylan Klebold and Eric Harris at Columbine, these men are invariably stuck in the emotional life of an adolescent. They always struggle with self-esteem – especially regarding women – and sometimes they give up entirely on the possibility of amorous fulfilment. There are different levels of tactical coordination, different ostensible grievances and different access to firearms, but the psyche beneath is invariably the same.

When Christopher Harper-Mercer fatally shot a professor and eight students at Umpqua Community College in Oregon on 1 October 2015, he revealed his own sexual frustrations, writing: ‘I am going to die friendless, girlfriendless, and a virgin.’ And before Elliot Rodger killed six people and injured 14 more near the University of California, Santa Barbara on 23 May 2014, he uploaded a YouTube video explaining his desire for dark ‘retribution’ – to punish women for rejecting him, and punish sexually active men for having more fun than him.

Robert L Dear Jr, who went on a shooting spree at Planned Parenthood in Colorado Springs on 27 November 2015, had been arrested years earlier after a neighbour complained that Dear hid in bushes and tried to peer into her house. An online personal ad posted by Dear sought partners for sadomasochistic sex. Most recently, Omar Mateen, who shot and killed 49 people at the Pulse bar in Orlando, Florida, was a failure with women – his two wives reported being afraid of his violent tendencies. And he might have been a deeply frustrated closeted homosexual, or at the very least obsessively fixated on sexuality.

It has become commonplace to argue that terrorist attacks are not about religion but politics or economics. Such interpretations usually recreate the terrorist as a cost-benefit actor, redressing economic or political imbalance. But if we’re willing to accept that these acts might only seem to be religious but are really something else, then we need to consider carefully whether we are right about the something else. Freudian interpretations of the news might be out of style, but we would do well to revitalise them (with updated data from social sciences and biology).

The facts of toxic masculinity are rarely discussed after mass shootings, as we beat the usual drums of gun control and mental health. Or toxic masculinity is blithely attributed to some patriarchal conspiracy that is unconsciously educated into boys. But consider the bigger, evolutionary picture. Social life requires the domestication of men. This is not some contemporary political interpretation of maleness. It’s a biological generalisation that applies to most social mammals. Intermale aggression must be turned into guardian instincts, if primate societies (such as ours) are to attain stability. Males must transform from little tyrants, competing for females, to selfless bodyguards and potential providers.

In a way, ontogeny recapitulates phylogeny, since the life history of a contemporary man seems to replicate the hominin trajectory of increased cooperation – increased pair bonding, increased male involvement in parenting, and the attendant emotional pacifications that are required. Even the biochemistry of the domesticated man changes, as fatherhood significantly reduces troublesome testosterone levels. This is the timeworn process in which young men become stakeholders in society. For the most part, men undertake this transformation willingly, but usually with conditions.

The ancient social contract, underwritten by androgens and oestrogens, is that a man will get a woman. He expects to get a partner, children and status. The execution of this ancient contract is imperfect and bears directly on the long historical record of male crime. As everyone knows, most violent crime is male (eg, a 2011 US Department of Justice report reveals that almost 90 per cent of all homicide perpetrators are men). Without a partner or sexual fulfilment, many men remain emotionally juvenile – aggressively impulsive, self-serving and potentially violent.

Young men who cannot find a place in the socialisation process will often take up a disdainful hostility towards domestication itself. The terminal rebel takes shape. A mild version of this was articulated two decades ago in Chuck Palahniuk’s now classic novel Fight Club (1996) and its later movie adaptation. But far more chilling than alienated urbanites secretly fighting in basements is the rise of ISIS, Boko Haram and other violently antisocial brotherhoods.

Historically, religions such as Islam and Christianity have played an important role in domesticating their respective male populations, but at a cost. Religion tries to manage eros for the sake of social harmony, but it does so indirectly by demonising desire and the body. The ascetic Christian presbyter Origen (184-254 CE) not only pronounced that his own body was alien to him, but was rumoured to have had himself castrated as a young man so that he could, without scandal, become a scriptural teacher for young women. Ascetic repressions, without creative outlet, often increase violent energy. Revenge fantasies and righteous religious narratives (that glorify suffering) help justify the punishment of everyone who is successful. Now add guns to the dynamic, and the story writes itself.

For the terminally frustrated male, the promise of women slaves is an enticing, albeit horrifying, recruitment tool

The jihadi loser has the ultimate frustration: as he develops through puberty, he acquires some of the most intense emotional drives of the human operating system – in particular, lust – but his culture informs him that his own desire, his own body, and the bodies of women, are impure and require repudiation. That interminable frustration can be channelled into a zealous mission to purify everything in the acid of an imaginary and bogus strain of religion. Male power is thought to be diminished – a kind of purity defilement – from uncontrolled women (the alluring single woman or the infidel) but when a woman is in some ‘appropriate’ state of affiliation (the obedient wife) there is no pollution and the male’s power is increased by his domination of her.

This is not essentially different from the sanctioned sexuality one finds in other Axial age religions, East and West. Indeed, Islam is historically far less concerned with sexual asceticism than Christianity, as the role model of the many-married Muhammad demonstrates by contrast with that of Jesus. Yet the fear and loathing of emancipated female sexuality is a palpable drive within contemporary radical Islam. And the rape cultures of Boko Haram and ISIS represent a further devolution of the ‘controlled female’ fantasy, with rape and slavery sanctified as an act of worship.

There’s little to no theological underpinning for this stuff, but there is an irresistibly tempting psychodynamic for frustrated young men who are easily drafted into a pathological band of brothers. For the terminally frustrated male, the promise of women slaves is an enticing, albeit horrifying, recruitment tool.

The pre-modern West also demonised desire. But in the contemporary West, natural sexual frustration is intensified by a culture that throws sex in your face at every turn, reminding you that you’re not getting any. These are existential issues because they resonate – rightly or wrongly – at the core of how many men see themselves. The problem is that many of our social norms and cultural narratives increase rather than defuse resentment. And resentment is the psychological fuel that gets the fire of violence going, whatever the ideological justification.

Resentment is the hunger for revenge, fed by the feeling of powerlessness. It was Friedrich Nietzsche who built upon Søren Kierkegaard’s use of the French word ressentiment to emphasise that this is far more than a subjective feeling. Ressentiment is also a value system and a moral appraisal of others’ actions. The individual who feels oppressed and excluded is feeling envy and insecurity, but he tells himself that he is in fact the morally superior being. Nietzsche argued that the whole of Christianity was born out of ressentiment: when the powerless Jewish minority inside the Roman Empire could not attain status in the oligarchic structures and the martial virtue system, they slowly reversed the Roman value system – making suffering into a virtue and weakness into ‘the good’. The arrogant Romans might run the empire, but the meek would inherit the kingdom of God.

Sigmund Freud expanded Nietzsche’s genealogical analysis of resentment into a more wide-ranging psychodynamic phenomenon – one that occurs in all of us, and still fuels social values and norms. Our obsession with fairness, for example, emerges out of our childhood resentment that others have more. As Freud wrote in Group Psychology and the Analysis of the Ego (1921): ‘If one cannot be the favourite oneself, at all events nobody else shall be the favourite.’

Lest you think this is just psychoanalytic speculation, consider the animal studies. The 2003 experiment by Frans de Waal and Sarah Brosnan on capuchin monkeys is often held to ‘prove’ the innate primate instinct of fairness. Two capuchins, in adjacent cages, were trained to take a token from a trainer and then trade the token back for a piece of food. Each monkey could easily witness the barter of the other. The food reward for this barter was usually a slice of cucumber, which capuchins like to eat. But grapes are loved by capuchins as a delicacy. If one monkey bartered her token and received only a cucumber slice, but then watched as the other monkey received a grape for the same kind of token, the first monkey would become incensed – refusing to play on, throwing cucumbers back at the experimenter, protesting and even punishing the lucky grape recipient.

This experiment has been over-interpreted by journalists and even scientists themselves to illustrate a fairness module in primates. Well-intentioned liberal academics regularly intone the experiment as an ancient ethical position that extends from grape payment to Occupy Wall Street and beyond. But I submit that the experiment does not illustrate an ancestral fairness module or even a fairness instinct. The actions of the capuchin monkeys are simply an expression of mammalian emotional systems, and do not appear to be moral (or normatively principled) at all. Envy and resentment are powerful in social animals, and while they might eventually scale up to social contracts, they are not moral per se.

Neuroscientists such as Jaak Panksepp and Kent Berridge have shown that primates like us, as well as other mammals, have a very strong seeking or wanting system (driven by dopamine). Once this desire system is triggered, it ratchets up expectation – motivating the mammal in powerful ways (toward food, sex, etc). Panksepp describes this blind intentionality as a ‘goad without a goal’, and this generic drive can be tethered to specific reward pursuits. The dopamine flood is at the high-water mark just before attaining the goal, not during the reward consummation. Now, thwarting or frustrating the culmination of that seeking drive immediately activates the rage system, and results in behaviours as trivial as tantrums or profound as murder. Rage is an innate brain circuit that runs from the amygdala regions, through the stria terminalis, to the hypothalamus and down to the periaqueductal gray of the midbrain. It is the same emotional neurochemistry, albeit ramped up, that propels the more extreme forms of ‘blowing your top’ or ‘running amok’.

Adult tantrums, filled with resentment, and facilitated by weapons, become tragedies in the order of the Orlando shooting

This is the science of resentment, and it adds the inner theoretical ‘guts’ to the organic resentment that Nietzsche and Freud observed. Or, to follow Freud’s hydraulic metaphor, it adds the fluid dynamics to the Id pressure-and-release system. When we add this neuroscience of frustration to the chimpanzee research, we observe that exasperation amplifies exponentially when we perceive (correctly or incorrectly) that others are satisfying their desires, and we are not. That perception transforms frustration into resentment and even rage.

It’s hard to admit that our high moral principles might be descended from temper tantrums, but just as a grown woman is no longer the little girl she was, so too our tantrums grow up and get converted into healthier social norms. Our tantrums evolve from personal feelings to reasoned principles with cognitive justifications for egalitarian notions of the good. The oak is not just the acorn. But what happens when our tantrums don’t grow up, don’t transmogrify into healthy impulses and norms of justice? Adult tantrums, filled with resentment, and facilitated by weapons, become tragedies in the order of the Orlando shooting.

These insights are important because it is not enough to simply label lone-wolf shooters and other malefactors as ‘mentally ill’. Toxic maleness, and the specific hydraulics of hate are grounded in originally adaptive biological structures, which need cultural management to find healthy expression. As the neuroscientist Joe Herbert pointed out earlier this year in Aeon, young men are coiled tight by testosterone, which drives risk-taking behaviour in the service of competition for females (the ancient adaptive imperative). Tilt the balance of young inter-male aggression just slightly, and you get the fanatic mindset that we see in jihadi movements and US antifederalist extremism alike.

My view is that the lone-wolf doesn’t have a theory as much as a feeling. Those feelings of resentment are a combination of thwarted affective drives (limbic system) plus cognitions about culpability (neocortex). The weaponised loser tries to make sense of his emotions by supplying causal stories and moral judgments about why he doesn’t have the sexual satisfactions, wealth or status that he expects. The people he thinks do have those satisfactions and freedoms must be brought low or punished, and the unattainable women who withhold their pleasures must be humiliated and destroyed.

The sociologist Jack Katz analyses the criminal mind in Seductions of Crime (1988), pointing out that many murderers see themselves, at least at the moment of slaughter, as righteous avengers. ‘What is the logic of rage,’ Katz asks, ‘such that it can grow so smoothly and quickly from humiliation and lead to righteous slaughter as its perfectly sensible (if only momentarily convincing) end?’ In both cases, the subject has a feeling of impotence or powerlessness. He feels victimised by forces outside himself (in the case of humiliation) and by forces inside himself (in the case of rage). The lone shooter who feels repeatedly humiliated at what he perceives as the visible success of others – the emancipation of women; the social acceptance of lesbian, gay, bisexual and transgender (LGBT) people; the integration of refugees – feels like his very identity is being broken and degraded. Rage promises to retake the situation and correct his perverse moral landscape.

The frustrated male casts about for a ‘cause’ of his misery, and mistakes the increasing power of newly emancipated communities for his depletion

The ‘logic’ Katz discovers is more topographic than syllogistic, but can be evidenced in the telling metaphors of ordinary language. Humiliation ‘lowers’ one. It makes one feel small. Humiliation reduces, diminishes, lessens, shrinks, dispirits, depresses, casts down. Rage reverses this downward trajectory. Rage ‘rises up’, ‘blows up’. ‘It may start in the pit of the stomach,’ Katz explains, ‘and soon threatens to burst out of the top of your head.’ The rageful are cautioned to keep their lids on, and not to blow their tops. In response to the descent of humiliation, rage might be said to be a psychological ascent (with terrible consequences).

The discrepancy between what the shooter wants and what he gets is eventually theorised, but in a lazy way – he adopts the ISIS ideology, or a Westboro Baptist Church-style Christianity, or homophobia, or antifederalist patriotism, or whatever is ready to hand. The frustrated male casts about for a ‘cause’ of his misery, and mistakes the increasing power of newly emancipated communities for his depletion. Whether it is the son of Muslim migrants who turns his rage on the LGBT community, or the hater of Muslim migrants who turns his rage upon the political champion of migration, the same hydraulic of hatred is at work.

The lone-wolf and the jihadist group might not be as far apart as we think. The fanatical ideology of ISIS or Boko Haram is just the last ingredient added to a bubbling cauldron of male frustration, rage and resentment. As the anthropologist Scott Atran wrote recently in Aeon, most jihadists don’t even know much about Islam. A few well-chosen pugilistic Quran quotes and homophobic or misogynistic slogans can rile up a resentful male to all kinds of evil. The wellspring of this evil is not in the religion, nor even the economic conditions, or the socially constructed patriarchy, but in profound, implacable resentment. Other factors converge, as Atran notes, to help sculpt resentment into warfare, including the ‘band of brothers’ promise of jihad – which answers to deep-seated social yearnings in isolated and alienated young men.

So what can be done? If male frustration and resentment is the unifying psychodynamic underneath homegrown lone-wolves and international extremists alike, then how do we address such root frustration? Every human society has contended with the challenge of containing and redirecting male frustration and rage: these responses can be categorised into a few varieties.

One well-worn path is that we should accommodate frustration. The conservative religious responses examined earlier fall into this accommodation paradigm. Most of these ‘endurance’ forms of asceticism try to overcome desire by devaluing the body, but there are healthier alternatives. Secular Stoicism and Buddhism, for example, offer less alienating therapies. In Buddhism one uses meditation to pry a space between our impulse and our action. The Buddhist recognises, for example, that he is filling with resentment in this moment, and that he can, with training, detach from that feeling and observe it. Detaching from resentment, and noticing its natural impermanence, is a way to attain some freedom over such enslaving passions.

Another major response to malignant frustration is redirection. In Civilization and Its Discontents (1930), Freud offered a taxonomy of three such redirection techniques: ‘powerful deflections’, ‘substitutive satisfactions’, and ‘intoxication’. The last of these needs little explanation beyond Freud’s own quoting of the German poet Wilhelm Busch: ‘The man who has cares, has brandy too.’ But powerful deflections, include the healthy distractions of work, be it physical or intellectual. Indeed, Voltaire’s Candide used gardening as a great diversion, keeping frustration and misery – and we could add resentment – at bay. Traditionally, African Samburu and Maasai groups carefully redirect the intense sexual frustration of young men – who are radically excluded from marriage by their elders until they reach their 30s – into cattle-raiding, hunting and warfare. This transforms a potentially toxic energy into something beneficial for the group.

it might be possible to reduce resentment by engineering actual libido satisfactions

Substitutive satisfactions include the myriad forms of distraction and surrogate fulfilment: art, fantasy, religion. In contemporary life, many young men channel aggression, resentment and unspent libido into hours of online gaming. Of course, it might prove difficult to wean a weaponised loser off a real-life action drama, and replace it with an Xbox or PlayStation version. Athletic sport remains a more promising redirect for excess libido, competitiveness and surplus energy – after all, George Orwell referred to international sport as ‘war minus the shooting’ – and even the sublimated violence of sport occasionally boils over into outright aggression, especially among hyper-aroused male fans.

Finally, besides accommodation and redirection of frustration, it might be possible to reduce resentment by engineering actual libido satisfactions – for example, many groups, including Amnesty International, think that sex work should be decriminalised, and this might allow a socially sanctioned means for the frustrated male to consummate his male identity without stigma. That is a controversial option, but it shouldn’t be ruled out a priori. In a seemingly sci-fi alternative, probably closer than we imagine, virtual reality sex and fembots are in mid-stage development among the Silicon Valley and Tokyo cognoscenti. Japanese sex dolls paired with virtual reality were unveiled to great delight at the Oculus Game Jam in 2013. And the US developer Matt McMullen is working on an ‘animate’ doll called Realbotix that promises to overcome our usual uncanny detachment from the surrogate human and give users an emotionally fulfilling sexual relationship. I have no idea if this sort of alternative to malignant frustration will work, but desire is a strange animal, and it has shown itself capable of diverse and unpredictable investments.

The thing that will not work, however, is just talking to men. Male desire and craving are not intellectualised away with some didactic lecture about how the brain or the economy works, or some sermon about what Jesus or Muhammad want from you. Desire must be redirected into some form of non-destructive expression, or defused, not just talked about. It’s the job of culture to help with this redirection, and the Abrahamic cultural traditions have outlived their effectiveness in doing so. We need to get working on some new cultural inventions to domesticate resentment and the hydraulics of hate, or the growing pack of weaponised losers will make political terrorism look tame by comparison.