This week, dozens of analysts and officials will be spending days huddled over desks, screens and phones, busy pursuing parallel inquiries into two young men of a similar age but dramatically divergent backgrounds. Many will be working for the same three-character organisations – the CIA, FBI, MI6, MI5 etc – in the US, UK or Europe. All will be seeking clues to help them achieve what has become one of the more pressing goals of our world: understanding extremism.

One set of investigators will be looking at the background of Younes Abouyaaqoub, the 22-year-old suspected of driving a van into crowds of tourists in Barcelona last Thursday afternoon, killing 14 and injuring scores more. The others will be piecing together the background of James Fields, 20, who has been charged with killing a young woman protesting at a neo-Nazi and white supremacist rally in Charlottesville, Virginia, on 12 August.

Immediately, a note of caution is needed. Fields and Abouyaaqoub are very different people, who have followed unique and contrasting pathways to violence. They grew up thousands of miles apart, in dramatically different circumstances.

More broadly, rightwing and jihadist violent extremism are distinct phenomena. Loathsome though their views might be, Vanguard America is very far from Isis, which is responsible for the suffering of millions and tens of thousands of deaths in the Islamic world and the west. Fields is no Mohamed Atta, who led the hijackers who killed 3,000 on the east coast of the US in 2001, either. So far, thankfully, there is no rightwing Osama bin Laden or Abu Bakr al-Baghdadi.

Studies have revealed significant differences in the profiles of Islamist and rightwing militants and their behaviour once radicalised, yet there is inevitably much that is shared. There is a mass of research into possible social factors that may render an individual vulnerable to extremist ideologies. One recurring element for jihadists is a distant or absent father. A recent study pointed at a difficult relationship with mothers as common among rightwing extremists. Fields’s mother twice called emergency services when he attacked or threatened her. The important role of the internet is clearly common, as is the crucial importance of small groups of individuals already committed to a cause, who can transform a new recruit’s tentative enthusiasm into hardened commitment. There is much, too, that is shared at an ideological level, once one looks beyond the obvious contrasts.

James Fields is accused of driving into protesters against a white supremacist rally in Charlottesville, Virginia. Photograph: Eze Amos/AP

One shared element is a rejection of authority, whether of an elected government or, in parts of the Islamic world, a monarch. Governments should be overthrown if they stand in the way of the rule of the enlightened and faithful, said Sayyid Qutb, the godfather of modern jihadist thinking, in the early 1960s. Rightwingers also see government as traitors to their imagined community, defined by “race” and sometimes faith, whose authority should be rejected and sometimes resisted.

Both believe their communities are facing an existential threat, placing an obligation on the individual to “resist”. Demography looms large for white supremacists, who make much of the possibility, raised by the US Census Bureau in 2008, that by 2050, minorities might make up more than 50% of the US population. Protesters at Charlottesville, parading beneath swastikas, shouted: “Jews will not replace us.”

For the Islamists, the belief that a belligerent west has been set on the humiliation and exploitation of the world’s Muslims for the best part of 1,000 years is axiomatic. There is also some consensus on the best strategies for resistance. In 1983, when far-right organisations were coming under immense pressure from the FBI, white nationalist Louis Beam published a manifesto calling for “leaderless resistance” to the US government. Beam, who was a member of the Ku Klux Klan and the Aryan Nations group, told his followers that only a movement based on “very small or even one-man cells of resistance… could combat the most powerful government on Earth”.

More than 20 years later, a Syrian called Mustafa Setmariam Nasar, better known as Abu Musab al-Suri, posted a sprawling set of writings on an extremist Islamist website, laying out a new strategy. His maxim was “principles, not organisations” and he envisaged individual attackers and cells, guided by texts published online, striking targets across the world.

Finally, there is the shared dependence on warped visions of history. Spain has been a particular focus of Islamic militants because of their obsession with al-Andalus, or Andalusia, the southern Iberian province that was ruled by Muslim sovereigns for centuries before being definitively reconquered by Christian kings in 1492. Al-Andalus is a symbol of the decline of great Muslim empires that for much of the past 1,300 years were infinitely richer, more powerful and more sophisticated than their western counterparts. This sense of loss is at the root of the attempt to re-establish the caliphate as a superpower that would restore the dignity of the ummah, the world’s Muslim community, as al-Baghdadi once explained.

Is there an equivalent of the caliphate on the right? The confederacy comes close in the US. Not in terms of historical reality, nor even as a current project, but as a mythic symbol of betrayal, of conviction and of what might, indeed should, have been. These warped visions comprise the most powerful and dangerous parallel between Islamist extremists and the rightwingers. Isis is working to establish a narrative that will turn the loss of their recently refounded caliphate and military defeat into a new call to arms. Many experts believe it will be a potent one, inspiring adherents even when the group itself has ceased to exist as a real force.

The grievance that comes with perceived loss and defeat is the lifeblood of extremism. It follows that the real danger from militant rightwingers will not come when, as now, they are full of confidence that the tides of history are in their favour, but when they sense the ebb. Donald Trump will not be in the White House for ever. The current empowering atmosphere for neo-Nazis will not last. We have not reached that point yet, but we may be hopeful that we do within a few years. However, it will not be a sign that victory is near, but that the toughest battles have yet to be fought.