It’s a recurring story in American media: a black man is subject to excessive punishment by the police. Often, this is chalked up to malicious discrimination, pure and simple. But new research conducted by myself and a team of collaborators (Tobias Rothmund, Mathias Twardawski, Natasha Thalla, and Jay Van Bavel) raises the question of whether acts of disproportionate punishment are, at least in part, due to psychological factors ingrained in us all.

We wanted to test what aspects of a transgressor’s identity would influence the amount that people believed he or she should be punished for a crime. To do this, we asked several hundred online subjects to play a three-person game. In the game, one player (let’s call him or her the punisher) observed someone else (the transgressor) “steal” a small amount of money from a third party (the victim). We then asked the punisher how much the transgressor should be punished for his or her crime.

We speculated that, because groups matter so much to people (even trivial groups, like sports teams and nationalities), the group membership of the transgressor would influence punishment. To test this, we manipulated the relationship between the punisher and the transgressor. In one experiment, for example, we told punishers that the transgressor was a fan of the same—or a different—sports team as them. In another, we told them that they were a citizen of the same or a different country.

We had predicted that people would punish out-group members more harshly than in-group. To our surprise, however, they did not. On the whole, people acted extremely fairly, meting out virtually identical levels of punishment to in-group and out-group members alike.

A different pattern emerged, however, when we deprived people of the opportunity to deliberate on their decision. In one experiment, for example, we distracted people by asking them to keep a 7-digit alphanumeric string in memory. In another, we focused on people who punished reflexively—that is, in a few seconds or less.

Both scenarios drastically changed the pattern of punishment. Suddenly, people were subjecting out-group members to vicious retribution and giving those in the in-group a pass.

These studies suggest that certain features of the human mind are prone to “intergroup bias” in punishment. While our slow, thoughtful deliberative side may desire to maintain strong standards of fairness and equality, our more basic, reflexive side may be prone to hostility and aggression to anyone deemed an outsider.

Indeed, this is consistent with what we know about the evolutionary heritage of our species, which spent thousands of years in tightly knit tribal groups competing for scarce resources on the African savannah. Intergroup bias may be tightly woven up in the fabric of everyone’s DNA, ready to emerge under conditions of hurry or stress.

But the picture of human relationships is not all bleak. Indeed, another line of research in which I am involved, led by Avital Mentovich, sheds light on the ways we might transcend the biases that lurk beneath the surface of the psyche.

In this research, we wanted to better understand when people succeed in treating members of different groups equally. Our investigations led us to focus on the concept of psychological distance. Taking psychological distance entails taking a metaphorical step back from the situation and seeing the “big picture.” For instance, considering why some event occurs, as opposed to getting bogged down in its specifics, is one technique by which people can establish psychological distance in a situation.

Psychological distance, our studies showed, greatly reduce intergroup discrepancies in treatment. For instance, psychological distance led people to be more likely to advocate for equal rights for non-U.S. citizens, to support equal pay for foreign workers, and to advocate for equal punishment of defendants, regardless of their appearance. This work suggests that removing ourselves from the heat of the moment and adopting a more distanced perspective can help us to see the common essence that underlies all human beings, thereby treating everyone more fairly and equally.

Overall, then, we should remember the dual nature of the brains we’ve been handed by evolution. On one hand, there’s the even-handed, fair, tempered side that gives rise to some of our most noble efforts and achievements. On the other hand, there is the crass, vulgar, quick-to-flare side that produces our most parochial and pernicious behavior.

Given the intrinsic appeal of both of these approaches to group-based behavior, it should come as no surprise when each of these competing drives manifest themselves on a larger scale at the level of our communities and societies—for instance, in the stances taken on the national stage by certain political candidates. Thankfully, for now at least, the choice remains up to us as to who we want to put in the driver’s seat.