David Sloan Wilson's career as a biologist started with zooplankton in the depths of the ocean and has ascended to God. He is convinced the same theoretical tools can be used to analyse the patterns of animal behaviour and human belief; and that the kinds of equations that tell you whether fish will be brightly or dully coloured, depending on the part of a river they live in, will also tell you why Calvinism thrived in 16th-century Geneva but the church of England is in decline today.

This ambition may smack of standard sociobiological imperialism - the belief that the other ways of looking at the world should defer to evolutionary biology. But Wilson's version has two twists. First, he does not believe biological understandings could or should replace the methods of the social sciences. He wants a commonwealth of knowledge, not an empire.

Secondly, he believes an essential tool for understanding social life is group selection. Anyone who has read the Selfish Gene will know the canonical history of modern biology starts with the rejection of group selection. Organisms are not selected for the good of their groups, but for the good they can do their genes. That seems to be the insight from which everything else springs; and it looks theoretically rock solid. If organisms appear to be acting altruistically, they must really be acting for the good of their genes.

The basis on which this argument rests is almost as simple as natural selection itself, says Wilson: "The fundamental problem of social life is that selfishness beats altruism within a group. But altruistic groups trump selfish groups. It's amazing that you can take such a controversial theory and describe it in two sentences."

He is a lean, mild man with large spectacles, who loves to talk. He is the son of a novelist, Sloan Wilson, who recently died but had great success in the 50s with The Man in the Grey Flannel Suit. "He was very scornful of religion, but both he and my mother were very moralistic. He used to hate - hate, hate - James Bond novels and novels in which people were glamorously portrayed killing each other.

"My decision to become a scientist was in part motivated by the fact that my father was such a famous novelist that I couldn't do that. But he did give me a love of writing. So there was a strange combination of wanting to please him and wanting to do something different. I wanted to be a scientist, and first I had in mind the kind of white-coated brain surgeon. Then I discovered it was possible to be an ecologist. I sometimes think of myself as a novelist trapped inside the body of a scientist. As soon as there was a way to study human beings within my discipline I moved to that."

One might say Wilson's entire scientific career has been an argument with the Selfish Gene. The central story of scientific development in that book goes something like this: once upon a time, biologists believed organisms could evolve to do things for the good of their groups. Then came the revolution, the new, tough-mindedness that showed this could not be true and that everything must be analysed in terms of the ruthless selfishness of its components. As Margaret Thatcher might have said, in the new biology there was no such thing as a species only individual organisms and their families.

In fact, the founders of selfish genery did not say groups could never matter - merely that the benefits of being in an altruistic group must outweigh the costs, even for altruists, as can be the case, when, say, the group enforces penalties on selfishness. Everyone agrees that, in principle, genes can spread by increasing the fitness of whole groups, despite being disadvantageous to their bearers. (The classic example of this is the bird that gives a warning cry to the rest of the flock but in doing so exposes its own location to the predator.) The controversy is over how often it happens in reality.

It may seem a simple twisting of words to say behaviour that's good for the group will be selected by evolution if it's also good for the individual. But the point is that this behaviour benefits individuals because they are group members. Behaviour can only be analysed and predicted by treating group selection as something that happens. "The idea that selfish gene theory by itself constitutes an argument against group selection is a common misunderstanding and the concept of selfish genes loses much of its force when revealed as merely newspeak for 'any gene that evolves, including by group selection'. Genes that evolve by group selection are as compatible with selfish gene theory as genes that evolve at any other level of selection."

Wilson, now a professor at Binghamton University, New York, first saw this as a graduate student in the early 70s: "I started out as an aquatic ecologist, but it was a very interesting time in the late 60s and early 70s because ecology, evolution and the study of behaviour were growing together. Everything could be studied with the same conceptual tools. All of a sudden you could build [mathematical] models that predicted how any particular species would behave. You could say things that applied across taxa, and that turned me into a theoretical biologist. I've always done theoretical and experimental work ever since.

"That was also a time when group selection was at its darkest hour. And for me, because I was ambitious, I thought that would be a wonderful thing to join in that controversy. I wanted to show how niceness evolves." Part of the answer turns out to involve the selective use of nastiness to punish breaches of the social contract - but that is jumping ahead of the story.

Wilson started with plankton. Because of the way they are broken up by currents, they naturally form patches or groups, on which selection can operate. He was interested in the way clumps of plankton move from the sunlit regions where they can feed, into the darker, safer depths. When he started to model this, he came up with a set of equations that showed how group selection could work in general and not just for plankton. With astonishing boldness, he went straight to the top, and announced his work to two of the giants of his field, starting with EO Wilson, who coined the term "sociobiology".

"I called EO Wilson on the phone, as a grad student, and I said, 'I want you to publish this in the Proceedings of the National Academy of Sciences,' and on my way to talk to him about the paper, called in on GC Williams." Williams, the author of Adaptation and Natural Selection, was the man whose criticism had done as much as anyone's to discredit group selection in the 60s. "I said, 'I am going to convince you about group selection,' and George offered me a postdoc on the spot. We've been friends ever since - ideologically opposed, but friends - and Wilson ultimately did publish the paper in PNAS."

Nonetheless, the acceptance of multi- level selection theory has been slow and patchy. "The individualistic perspective had taken a huge hold on the whole field. Explaining everything in terms of self-interest had become, now, such a powerful metaphor that it could not be opposed. Individualism eclipsed groupism everywhere, in biology, in the social sciences, and in everyday life. In many ways I go along with the received wisdom that there was lot of pervasive naive group selectionism in the 50s and 60s. But now we have a sophisticated group selectionism that shows how societies can truly qualify as adaptive units in the same sense that individual organisms are adaptive units."

The decisive turn, he believes, came with the theory of evolutionary transitions. This undermined the faith that groups couldn't be treated as single organisms by showing that the organisms around us themselves originated in "social" groups of bacteria or simpler cells. For example, eukaryotic cells - those with nuclei - seem to have formed by the symbiotic union of simpler bacteria. What started as the cooperation between separate bacteria ended in the creation of one indivisible cell. This illustrates a more general principle: "Sometimes, social groups become so functionally integrated that they become higher-level organisms in their own right."

Organisms large enough to see are made up of eukaryotic cells that behave altruistically towards others in the body (when they stop doing so, we call it cancer). This transition is complex. Being multi-cellular, and coordinating the interests of the different cells in a body is not easy: about half our genes are needed for these "housekeeping" processes, which is why we share half our genes with a banana.

The individual cells, of course, cannot feel altruistic emotions. Their be haviour is "altruistic" in a biological sense; the great question is whether our altruistic emotions have evolved to make us behave in ways that a biologist can recognise, and analyse, as being altruistic in the context of our social groups. If this is true, certain consequences must follow. The first is that the emotions we recognise as altruistic will be accompanied by others we think of as unpleasant. Moralistic aggression - the punishment of antisocial behaviour - is just as important in keeping groups together as are warm fuzzy feelings of belonging. "If a group is going to be a corporate unit then moral decisions must apply to all members," says Wilson. This explains why we instinctively feel that moral norms are absolute, so if they don't apply to everyone, they are not properly moral.

The important thing about religion, he thinks, is that it encourages collective action. The emotions that religions build on, and the conduct they encourage, tend to bind groups and build cooperation. The worship of a common god, he believes, is really the worship of a common good, to whom everyone in the tribe or religion must defer.

His most recent book, Darwin's Cathedral, takes a serious shot at explaining religious belief in this way. It is, he says, a biological and cultural adaptation to build cooperation. This does not mean religious emotions are about cooperation. Evolution doesn't work like that, as a comparison with fleshly love makes clear. No one doubts that our sex drives are an adaptation to ensure we have babies. But our emotional drive isn't for children. It's for sex.

In the same way, says Wilson, "spirituality, this intense searching for God, reliably leads to community. The monastic and ascetic tradition actually ends up being involved in communitarian activities. This is true across all religions. When you look at it closely, these people sitting in caves in the Tibetan mountains and the fabled ascetics of early Christianity, the people sitting on poles in the desert and so on, are plugged into a wider lay network.

"Sacredness needs to be studied outside a religious context. A sacred symbol is one that is dominating us, whereas something profane is a symbol we can dominate. To call something sacred is to give it power to coordinate and organise society."

His view of religion is in almost every respect the opposite of the Dawkins view that religion is a matter of false and perhaps malevolent beliefs. That they are false is almost the least important thing about them compared to the effect they have on our behaviour. If they promote advantageous behaviour, or group cohesion, religious beliefs will survive. The one thing religions take seriously is not their theories of creation. Or even of the after-life - many religions don't involve any coherent belief in heaven. It is their rules about how believers must treat one another, and outsiders. If these are got right, the religion will flourish, even if its doctrines are absurd. "One point is just how radically different this is to other approaches to religion and science," he says. "It completely turns creationism on its head. It says there is a scientific explanation for creationism."

Further reading

Darwin's Cathedral, by David Sloan Wilson. University of Chicago Press (2002). ISBN 0226901343.