Sarah Palin, Senator John McCain�s running mate, finds it easy to spot where the deity is at work. The Lord God, apparently, is in favour of a $30bn Alaskan national gas pipeline project. (The big oil companies agree with God.)

Sarah Palin, Senator John McCain's running mate, finds it easy to spot where the deity is at work. The Lord God, apparently, is in favour of a $30bn Alaskan national gas pipeline project. (The big oil companies agree with God.) The invasion of Iraq was a "task from God" in the view of the Alaskan governor. Like the late televangelist, Jerry Falwell, who declared that the 9/11 attacks were punishment for America's tolerance of gays, America's gun-toting super "hockey mom" seems pretty familiar with the working of the creator's mind. Well, God help us all.

Chirpy certainty about the activities of the deity should have perished in the gas chambers and gulags of the twentieth century. Where precisely was God during the Holocaust, when six million of his chosen people - lucky, eh? - perished in the gas chambers at the hands of operatives who were often cultured, Christian, and often sporting Gott Mit Uns - "God is with us" - on their belt buckles? This is the question which lay at the heart of last week's stunning BBC2 drama, God on Trial. Commissioned by BBC Scotland and filmed on location in Glasgow - it's still available on BBC iPlayer for the next three days - this was television at its brilliant best. It was inspired by a possibly true, probably apocryphal story that in Auschwitz a group of inmates decided to put God in the dock, charged with breaking his covenant with his chosen people.

In the film, the trial takes place in a camp blockhouse over the course of one day. Now, you might think that a 90-minute discussion about theology conducted within the confines of one room would be well short of riveting; in fact it is electrifying. This is in part owing to stunning performances by the likes of Sir Anthony Sher and Rupert Graves, and to a superb, uncompromising script by Frank Cottrell Boyce (of Welcome to Sarajevo fame); but the fact that this theological engagement is undertaken with passion and rigour by desperate men in the striped shirts of the already-damned ensures that the court drama is always on the edge.

It's touching that in the midst of the nightmarish moral disorder of the Nazis' final solution, the court is established according to rabbinic principles.

God, fighting for his life in the supreme court of Auschwitz, is defended by some passionate and learned comforters, but the evidence against him piles up. Not just the prisoners, but God himself is dying before our eyes. I am reminded of a passage in Eli Wiesel's searing memoir, Night, in which camp prisoners are watching public executions. "Behind me, I heard a man asking: Where is God now?' And I heard a voice within me answer him: Where is He? Here He is. He is hanging here on the gallows.' That night the soup tasted of corpses."

There are things which reduce - or should reduce - religious people to silence. There are times when the ways of God cannot be justified to men. The religious tradition I know best, Christianity - which, of course, has the image of a suffering God on the gallows at its core - does not work best as a form of justification or explanation. The devil, as Job well knew, is in the detail. In the Auschwitz courtroom, the three judges return a guilty verdict against a deity who in many sacred texts acts like a lover, but in some others like Radovan Karadzic.

So that's that, then? Well, no. As the guards come to take away the prisoners selected for death, a murmur of prayer begins. Even those who have argued vociferously against God join in the swelling praise. The God they have found guilty is worshipped in the Psalmist's words: "O God who is our refuge from age to age . . ."

In this camp of death, those who cannot live with God also find they cannot live without him.

Religions are not determined by reason. (That doesn't mean they are irrational.) They are of the heart, stammering the inadequate human poetry of transcendence. They can be both sublime and terrible, awe-full and awful. Their rituals and scriptures are communal resources for living and dying and mourning and yearning. They are sets of practices even more than they are belief systems; that is partly what it means to be, for instance, a practising Christian. One can be a practising Christian in another sense: experimenting, rehearsing, living "as if".

Auschwitz not only exposes the bestial underbelly of humanity; even as it tests the idea of a loving God to the point of destruction, it fails to hide the glory of the human spirit, and cannot prevent the prayers of God-haunted people leaking from its obscene and terrifying chimneys. It also brings to an end cheap talk about God - at least, among consenting adults.