I recently watched one of the most brutal and upsetting films I've ever seen, called The Stoning of Soraya M. I suppose the title of this 2008 film should have warned me away, but I really don't believe that anything could prepare viewers for the graphic, bloody and excruciatingly prolonged scene that gives the film its name. It's the story of a 35-year-old mother, falsely accused of adultery by her bullying husband and local mullah, who is convicted under Islamic law and executed by the men of a rural Iranian village. The stoning, based on a true story, took place in 1986, but the small-mindedness and hate-filled religiosity are medieval.

The Stoning of Soraya M. is an indictment of Islamic fundamentalism and misogyny in post-Revolution Iran. The outrage of the film derives from the fact that this cruel execution is prescribed by Sharia law. Yet we all know that Islamic fundamentalists don't have a corner on religious intolerance and hateful violence. It's one of the paradoxes of human history that religious faith, the wellspring of morality and universal love, is also the source of so much cruelty and injustice, including cold-blooded murder.

Why is it that religious belief and teaching do not lead to moral action? What is it about religious thinking that it can create both kindness and hatefulness from the same basic beliefs? Philosophers and theologians have struggled for centuries over this riddle of human behavior, and more recently, psychological scientists have begun applying their experimental tools to explore this baffling truth. Two of these experts on religious cognition, Jesse Lee Preston and Ryan Ritter of the University of Illinois at Urbana-Champaign, have an original hypothesis about the disconnection between religion and morality, and some preliminary evidence to back it up.

One possibility, Preston and Ritter say, is that the good side of religion -- the altruism, community building, inclusiveness -- is not universal at all, but instead is reserved only for others of the same church or sect -- or in the case of Soraya's Iran, only the fundamentalist men. In this sense, religion is not just a belief system, but also a form of group affiliation, an in-group that excludes many more than it welcomes. The love and kindness are tightly restricted.

This does not of course preclude a personal and spiritual aspect of religion, including a genuine concern for all others, even those who don't attend the same church or mosque or temple. Religious belief can be inclusive rather that exclusive, promoting the kind of altruistic behavior most of us associate with the great religious teachings. The love and kindness are universal.

According to Preston and Ritter, these two distinct sides of religious beliefs reflect the difference between institutional religion, on the one hand, and God on the other. Religion and God are not synonymous. They have different psychological roots, and lead to very different human actions. That's the idea that the Illinois scientists decided to test in the lab, by priming peoples' thinking and observing their behavior. They suspected that reminders of religion would promote insular thinking and restrict caring to the in-group. Reminders of God, by contrast, should activate concerns for moral virtue more broadly, leading to a more inclusive kind of generosity.

In the first experiment, volunteers sat at a computer screen, where they played a game called the "Prisoner's Dilemma," which gives each player a choice between being cooperative or self-serving. In this version of the game, cooperation required personal sacrifice, and it was also anonymous, so there was no expectation of payback. Although the volunteers were playing the game with an unseen partner, they were given a quick glimpse of the other player's photo. Sometimes, the other player was white; others time, Indian. In other words, they knew if they were being asked to cooperate with someone like them or unlike them.

Before playing the game, the volunteers were subliminally primed -- some with the word God, others with the word religion. The idea was to see if those primed to think about religion would be more generous toward their own in-group than were the others. And they were, dramatically so. The concept of religion clearly made them want to circle the wagons and help their own. What's more, those primed to think about God -- not about religion -- were more cooperative with out-group members, compared to the religiously primed. In fact -- and this was surprising -- those thinking of God were more generous to outsiders than they were to insiders -- suggesting a kind of "egotistic" generosity. It seems they were motivated by a desire to appear selfless, more than they were motivated by genuine altruism.

The scientists wanted to explore this dynamic further. So in a second experiment, they looked at the effects of priming on acts of charity in a real-life situation. The study was done in the spring of 2009, shortly after the first outbreak of swine flu. People were confused and a bit panicked about the risk of illness and death -- and scientists still had no clear answers. The number of confirmed cases was rising daily, though at that point they had only been reported in the U.S. and Mexico.

The scientists took advantage of this public health threat to conduct their study. As before, some volunteers were primed to think about religion -- specifically their own church affiliation -- and others were primed to think about God. Then all the volunteers took a short survey about their health, nutrition and exercise habits. This was meant to get them thinking about their own health. Finally, all were given the opportunity to allocate a charitable donation to the American Red Cross and the Mexican Red Cross, dividing the cash up in any way they chose. The scientists wanted to see if those who were thinking about their own church would act more or less charitably toward Americans and Mexicans.

The results were basically the same as before. As Preston summarized at this week's meeting of the Association for Psychological Science, in Chicago, those with religion and church on their minds gave more money to Americans than to Mexicans. That is, they restricted their charity to others like themselves. Those with God on their minds gave more to people unlike them -- showing the same out-group bias as before. Interestingly, religious identity trumped even nationality as an in-group identity: Catholics -- but not non-Catholics -- gave more money to the Mexican Red Cross when primed with religion, but more money to the American Red Cross when primed with thoughts of the deity.

Religion also trumps nationality in the tragic death of the guiltless Soraya M. She is not the victim of secular law, and indeed the only secular authority -- the mayor -- must be tricked into condoning the punishment. She is the victim of the more powerful religious law, applied mercilessly by an insular group of zealots. The hero of the story is Soraya's aunt, the devoutly religious Zahra, who would sacrifice herself to save Soraya. She connives to leak the story to a traveling journalist, and thus to the world, and in the final scene, as she delivers the incriminating evidence to the writer, it is Zahra who proclaims: "God is great!"