The question: What can science fiction tell us about God?

At its best, of course, science fiction is a serious literature of ideas that explores them through three-dimensional characters and fine style; like most of us, SF has those mornings when it is not at its best, but even then it is a form that has interesting things to say about almost everything. A lot of the founding parents of SF were slightly dogmatic agnostic progressives who generally saw religion as obscurantist and reactionary; if you are writing technophilic social satire, cardinals and high priests are almost a default set of villains. More interestingly, religion offered both gaudy backdrops for stories and interesting ideas from which stories could grow.

Some of the most famous SF stories and novels are directly involved with religion at the level of ideas. Arthur C Clarke was very much not a believer, but his The Star, a short story, is sympathetic to the crisis of faith of a Jesuit astronomer who discovers that the Star of Bethlehem was a nova that wiped out a civilisation. Another Jesuit – SF has always been fond of that most intellectual of orders – is the hero of James Blish's A Case of Conscience, who is confronted with a species that appears to be both entirely without religion and virtuous to the point of seeming Unfallen. Other writers have dealt with the possibility that aliens have immortal souls (but we don't), that God doesn't exist until a large enough computer is turned on, or that God might tire of us and decide to give the mandate of heaven to alien invaders.

Other writers are more interested in religion as a lived experience – the point of Walter Miller's A Canticle for Leibowitz is not just the idea of monasteries keeping scientific knowledge alive after an atomic war, so much as the sense of monks giving their lives to illuminating copies of blueprints that they cannot read or understand. A lot of Philip K Dick's books are full of bizarre cults – a drug-induced fascination with the inhabitants of dollhouses or a virtual reality participation in the hard pilgrimage of a messiah figure – but again it is less the idea that matters to him than the way people find such things fulfilling.

It is perhaps because religious and mystical experience lies outside the comfort zone of the sort of person who reads or writes SF that when people actually consider the matter seriously, they up their game. This is perhaps especially the case when the religion involved is not the one the author grew up with links to – the late George Alec Effinger wrote a particularly fine series of detective stories set in a future North Africa – When Gravity Fails and its sequels – with a Chandleresque detective whose attempts to be a good Muslim are just another part of his angst. (British writers like Jon Courtenay Grimwood in Effendi and Ian McDonald in The Dervish House have also engaged sympathetically with Islam as a rich religious culture.) Sometimes, the religion is a response to particular circumstances – Donald Kingsbury's Courtship Rite gives us human colonists of an alien planet who have built an entire religion round the fact that human flesh is the only available meat – religion can be how people live with the otherwise unendurable.

And then there are aliens, and aliens have their own gods too, or don't until human beings come along and perturb their innocence with religion. Again, a lot of the time, the point is to ask the question "what if?" with aliens acting as exotic surrogates for human beings – one of the Greek philosophers suggested that if cows had gods, they would be cattle, and many fictional aliens have religions that reflect their bug-eyed or reptilian status. Sometimes the alien religion is just exotic dressing on a story that is really about the here and now – there is an episode of the TV show Babylon 5 which is a thinly disguised picture of medical dilemmas that arise from some church's objections to blood transfusion; sometimes, though, the religion is far more rich and strange – the humans and aliens of Iain M Banks's recent Surface Detail are in some cases obsessed with creating a hellish afterlife in virtual reality to ensure the wicked are punished, and in others with liberating them.

The one thing that cannot be said about SF's attitude to religion is that it is pious – SF is a fundamentally irreverent literary form which is never really happy with certainty or solemnity. It is perhaps for that reason that some American fundamentalists put it on the list of forbidden genres along with books about witchcraft and wizards. SF is not hostile, essentially, to religion, but it is not comfortable with closed minds.