The two faces of modern religion were on stark display in Britain this week. In Canterbury, the much-abused anti-war archbishop, Rowan Williams, used his Easter sermon to launch a powerful attack on individualist consumerism and "the greed of societies that assume there will always be enough to meet their desires -enough oil, enough power, enough territory". Meanwhile in Edinburgh, the conservative Cardinal Keith O'Brien, leader of Scotland's Catholics, denounced the government for a "monstrous attack on human rights" through its "evil" endorsement of "Frankenstein" experiments. There are clearly serious arguments about the government's embryology bill and its licensing of the use of empty animal eggs for short-term human stem-cell research into life-destroying diseases, but the message from the cardinal's outburst was plain: in his wing of the church, the policing of sexuality and procreation trumps the cause of human suffering and liberation every time.

For the militant secularists whose voices have grown ever louder in recent years, O'Brien's is the only face of religion that matters. This has been the decade of liberal rage against religion, reflected in the runaway success of books like Richard Dawkins' The God Delusion and Christopher Hitchens' God Is Not Great. In the eyes of secular absolutists - whose attitudes uncannily mirror those of religious literalists - religion is simply an intellectual travesty, a perverse belief in a supernatural being and an affront to the enlightenment that refuses to die. As the novelist Martin Amis declared recently: "Opposition to religion occupies the high ground, intellectually and morally."

Entirely missing from their perspective is the social context and significance of the religious resurgence they are so anxious to beat back. Panicked by the rise of radical Islamism and the newly assertive religious identity of migrant communities in a secular Europe, the anti-religious evangelists are increasingly using atheism as a banner for the defence of the global liberal capitalist order and the wars fought since 2001 to assert its dominance. At the same time, they are unable to recognise the ethnic dimension of their Islamophobia, let alone the deeper reasons why people continue to search for spiritual meaning in a grossly destructive economic environment where social alternatives have been pronounced dead and narcissistic consumption is king.

Historically, of course, it was the left, rather than liberalism, that was most hostile to religion. From Tsarist Russia to Tibet, after all, organised religion stood with the established order, preaching social deference to the powers that be and leaving hope of justice to the hereafter. But as religion has declined in Europe and elsewhere and capitalism has eroded the ties binding religious institutions to ruling elites, that has become ever less true.

In the wake of the cold war, the pressure on the Catholic church to struggle against godless communism disappeared, and the pope who had played such a key role in its demise became one of the few international figures in the 1990s to speak out against "savage capitalism" and western warmongering. At the same time, Islamist groups which had provided crucial support for conservative pro-western regimes around the Muslim world in the postwar era began to fill the political space left by the decline of Arab nationalism and the left, increasingly drawing their support from the poor and marginalised.

Religion cannot but now find itself in conflict with the unfettered rule of money - a capitalism that seeks to dominate exactly the social and personal arena which religion has always regarded as its own preserve. And as it becomes less useful as an ideological prop for power, religion's more radical and anti-establishment strains have become stronger. That is the context in which, for example, Hugo Chávez of Venezuela declares Jesus as the first socialist and Che Guevara-style images of the founder of Christianity are carried on demonstrations in Caracas.

Not that there should be any difficulty in extracting a radical social message from religious traditions, though you'd never know it from grim textual exegesis favoured by the militant secularists. The rightwing bishop Michael Nazar-Ali - who recently blamed multiculturalism for supposed "no-go" Muslim areas - tried to argue at the weekend that Jesus had been guilty of "typical Middle Eastern exaggeration" when he warned that "it is easier for a camel to go through the eye of a needle than for a rich man to enter the kingdom of God": a hard case to sustain, given the similar message of downfall for the rich and liberation for the poor in the Magnificat, the sermon on the mount, Jesus's exhortatory quotations from the prophet Isaiah, or the even more militant epistle of James.

No wonder the medieval church tried so hard to prevent people reading such incendiary stuff in their own language. But similar demands for equality and social justice can of course also be found in Judaism ("you shall not oppress a stranger"), Islam ("a white has no superiority over a black nor a black over a white"), and other religions.

None of that is to deny the strength of regressive trends within religion and its texts, from the Vatican's opposition to contraception in Aids-blighted Africa, to Hindu nationalism, takfiri Islam, or the power of rightwing US evangelicals (though that is mercifully now loosening). Nor does it in any way imply compromise with social conservatism over women's or gay rights. But it does highlight the scope for stronger alliances between the secular left and religious progressives against poverty, capitalism and war - an engagement that has the potential to change both sides in other ways, too. The National Union of Teachers' proposal for secular schools to offer religious instruction as a way out of the faith school controversy is one such positive attempt at engagement.

Just as the French republican tradition of liberation came to be used as a stick to beat Muslims in a completely different social context from which it emerged, so the militant secularists who fetishise metaphysics and cosmology as a reason to declare the religious beyond the liberal pale are now ending up as apologists for western supremacism and violence. Like nationalism, religion can play a reactionary or a progressive role, and the struggle is now within it, not against it. For the future, it can be an ally of radical change.

s.milne@theguardian.com