It's a commonplace that wars and religions are closely associated. Since about 1945 there has been an increasing tendency for wars to be fought along religious, as well as ethnic, economic and cultural lines, though I don't think many people realise that the most warlike religion in the modern world, measured by the proportion of countries at war where it has a significant following, is actually Buddhism.

But which comes first? Religion or violence?

I was talking in a panel discussion organised by Sussex University and International Alert at the Royal Commonwealth Society on this matter earlier in the week, and for once a new idea emerged from our exchanges. It has always seemed clear that violence recruits ideology at least as much as ideology incites violence, but why should it be religious ideologies in particular that are recruited?

I have until now supposed that it is precisely their irrational and absolute character that makes them useful in a serious conflict. This point tends to be lost on the reasonable types who suppose that all conflicts can be solved by negotiations. I think that's far too optimistic, and that Conor Cruise O'Brien was right when he distinguished between problems, which have solutions, and conflicts, which only have outcomes. There really are situations in the world when both sides cannot get anything they might reasonably settle for. One or the other must clearly lose.

In those desperate situations, the last person you want on your side is a reasonable friend acting in rational self-interest. At some stage their rational self-interest will demand that they dump you. No, in a real struggle you want friends who are tied to you not by contract, but by covenant: by blind and unconditional loyalty rather than by calculations of advantage.

But is there any necessary link with religion? Could we not just as well have blindly and fanatically loyal atheists, who will sacrifice their own lives almost as readily as they will sacrifice others? History shows that we can. The Red Army in 1945, the communist volunteers in the Spanish civil war, and the Viet Cong and their allies, all fought with exceptional bravery and savagery. In this context there is a lovely anecdote in Claud Cockburn's memoirs about a militia troop in the Spanish civil war that found itself billeted in a church and would not, could not sleep until they had shot off all the heads of the statues and icons that would otherwise have watched them.

Then there were outbursts of atheist terrorism in the 70s – the Baader-Meinhof gang in Germany, the Montoneros in Argentina, the Red Brigades in Italy, the Tamil Tigers in Sri Lanka. But for the most part, and increasingly, the large-scale movements of fanatical violence in the world have since then been religious.

I'm not saying this to draw up a score card. The question isn't whether "religion" is morally better or worse than atheism. The interesting, and novel, question is whether there is any reason why nihilistic and violent ideologies should sometimes be religious and at other times atheistic.

What makes sense of this pattern is the growing and settled secularism of the dominant culture in the latter part of the 20th century. One of the things that nurtures fanaticism is a distance from the surrounding culture. That's what makes you feel alienated and threatened for your beliefs. In milder form this syndrome produces "cults", turning orthodox Hindus into Hare Krishnas. In pathological forms, it makes dangerous fanatics.

So, rebellion against the dominant culture will increasingly look for ideologies that are alien to it. When Europe was predominantly Christian, these ideologies of opposition were atheist or nationalist. Since 1980, more or less, the settled world order has been secularist and without any explicit religious framework. So if you want to rebel against it, a religious motivation may be needed to help provide the necessary distance.

As I said, this isn't a score card. Human beings are so wonderfully imaginative and creative that we will always find ways to hate and dehumanise one another, irrespective of (a)theologies. But it does seem a helpful way to think about when and why some ways of hatred are more popular and more effective.