Last year, Dimitris Xygalatas, the head of the experimental anthropology lab at the University of Connecticut, decided to conduct a curious experiment in Mauritius, during the annual Thaipusam festival, a celebration of the Hindu god Murugan. For the ten days prior to the festival, devotees abstain from meat and sex. As the festival begins, they can choose to show their devotion in the form of several communal rituals. One is fairly mild. It involves communal prayer and singing beside the temple devoted to Murugan, on the top of a mountain. The other, however—the Kavadi—is one of the more painful modern religious rituals still in practice. Participants must pierce multiple parts of their bodies with needles and skewers and attach hooks to their backs, with which they then drag a cart for more than four hours. After that, they climb the mountain where Murugan’s temple is located.

Immediately after each ritual was complete, the worshippers were asked if they would be willing to spend a few minutes answering some questions in a room near the temple. Xygalatas had them rate their experience, their attitude toward others, and their religiosity. Then he asked them a simple question: They would be paid two hundred rupees for their participation (about two days’ wages for an unskilled worker); did they want to anonymously donate any of those earnings to the temple? His goal was to figure out if the pain of the Kavadi led to increased affinity for the temple.

For centuries, societies have used pain as a way of creating deep bonds. There are religious rites, such as self-flagellation, solitary pilgrimages, and physical mutilation. There are the rites of passage into adulthood, like the Melanesian rite where boys “may be extensively burned, permanently scarred and mutilated, dehydrated, beaten, and have objects inserted in sensitive areas such as the nasal septum, the base of the spine, the tongue, and the penis.” There are also the less intense initiation rituals of fraternity houses and military branches, of summer camps and medical residencies. Painful rites seem to be a way of engineering the kind of affinity that arises naturally among people who have suffered similar traumatic experiences.

Psychologists have also long believed that pain creates exceptional bonds, and researchers have been running experiments, somewhat like Xygalatas’s, since the nineteen-fifties. Some of the earliest findings date back to Elliot Aronson, a Stanford University psychologist who had studied under Leon Festinger, the man who came up with the idea of cognitive dissonance. In 1959, Aronson found that the more painful the experience a young woman had to go through in order to join a community, the more she valued the group. Aronson, true to his roots, attributed the effect to dissonance reduction: you want to justify to yourself that the pain was worth it. More than fifty years later, and far from Palo Alto, Xygalatas concluded much the same thing.

When Xygalatas and his colleagues analyzed the donations to Murugan’s temple, they found a substantial difference between the groups. Those who had gone through the Kavadi were willing to give an average of a hundred and thirty-four rupees to the temple. Those who had engaged in prayer and song offered only eighty-one rupees. Notably, there were no differences in religiosity between the groups. It wasn’t that the more faithful were more likely to endure the painful ritual and also to donate more money; the data showed that the pain of the ritual itself had made them more generous toward their group.

One explanation for the finding is the classic one: that the value comes from dissonance reduction and the need to convince yourself that a painful exercise was worth it. Another theory, however, derives from something closer to the idea expressed by Emile Durkheim, writing in “The Elementary Forms of the Religious Life, Part 2,” that pain, when it does not occur naturally, creates communal bonds in part because “suffering creates exceptional strength.” The willingness and ability to endure pain for some greater cause tells you something about yourself and your fellow sufferers. A club is more valuable to you if you and everyone else endured feats of extreme physical endurance to enter it. Indeed, a study of injury among corps de ballet members of the Royal Ballet and former dancers who had been injured enough to end their careers found that pain was seen as both essential and defining for a dancer. “Part of the discipline is to have pain,” one dancer observed. Another made an injury a point of pride: “I danced hard with a sprained ankle, on a sprain!” Because ballet is such a physically grueling sport, and injury such a common occurrence, it is itself almost a mark of dedication and commitment. If you are injured, you are training hard. If you dance through an injury, you are committed to your success. Pain becomes a signal of your suffering, which reveals your identity and your loyalty to the group. You love ballet in part because everyone in it gets hurt; you love temple more because everyone who reached it had to suffer so much.

There’s another question, though, that stems from the work of Xygalatas and others. What if there’s no group to begin with? Can shared pain itself be enough to forge bonds of group loyalty?

This is something that the social psychologist Brock Bastian has been studying for the last five years. Pain, he’s found, seems to play a central role in a group experience in a way that a pleasurable or neutral bonding experience simply doesn’t. “It’s a part of everyday life and we often seek it out in a number of ways,” Bastian told me. “We tend to overvalue pleasure, but pain is a central part of what it means to be human and what makes us happy.”

This fall, he and his colleagues at the University of New South Wales and the University of Queensland set out to test whether the experience of pain itself was enough to create a group where none existed before—pain in its own right as the forger of social bonds. First, the researchers split students into two groups: members of one would be forced to submerge their hands in ice water for as long as they could while trying to locate small balls at the bottom of the basin and place them in a submerged container; members of the other would perform the same task, but, instead of ice, their hands would be in room-temperature water for a minute and a half. During the experiment, everyone could see the other members of the group.

Next, members of the ice group would have do a wall squat (back against the wall, knees bent at a right angle—a painful position to maintain for an extended period), while members of the room-temperature group would be asked to balance on one foot, with the option to hold onto something or switch feet any time they wanted. At the end of the study, Bastian asked each individual how much pain she had experienced, and how she felt about her fellow study participants. The students who had endured the icy water and wall squats had not only felt more pain but had perceived a stronger bond with their fellow sufferers. They felt more solidarity with them and more loyalty to them—and they felt strongly that the experiment had created unity. Those who had participated in the non-painful version of the experiment felt no such thing.