The way we behave when threatened sometimes goes against conventional wisdom: we soften up. Andrew White, a PhD student at Arizona State University, and his colleagues analyzed data from 54 nations and found that the more a nation spent on its military (presumably a good index of perceived threat), the higher its people scored on self-report measures of how agreeable they were to others.

This trend, published in the October 2012 issue of Interpersonal Relations and Group Processes, held all the way down to the individual level: People who believe the world is a dangerous place reported being more agreeable than those who don’t.

“It is a very nice contribution to the literature on prosocial behavior,” says Paul A. M. van Lange, a social psychology professor at Vrije University Amsterdam, who was not part of this study. “Many people think in terms of mental shortcuts or heuristics: aggression leads to aggression and niceness leads to niceness. But to understand human thought and behavior, one should go deeper.”

As White continued to dig, he found there was a twist to these findings: While people do become kinder to their kin, they get nastier in the presence of strangers. Those “agreeable” people in countries with big defense budgets are less trusting of members of other nationalities or religious groups.

Threat also shapes how an individual acts towards an “out-group.” White and colleagues showed this by putting up two types of posters (threatening and nonthreatening) around their university and seeing how many students would respond to a call to volunteer for an in-group or an out-group. The threat poster depicted a large gun pointed at the viewer and encouraged students to become aware of a new law that allows guns on campus. The non-threat poster was an image of a crane and promoted awareness of new construction underway at the university. Half the gun posters had an adjacent post that asked for student volunteers for an upcoming event organized by the “Arizona Student Association.” For the other half of the gun posters, the post noted the “Ethiopian Student Association” as the coordinating body. The same was done for the construction posters. A.S.U. students were much less generous in donating their time to the out-group (Ethiopian students) and more supportive of their in-group when they saw the gun poster.

“The data seems to support the ‘circling of the wagons’ idea,” says Douglas Kenrick, co-author and lead researcher of A.S.U.’s Evolutionary Social Cognition Lab. “If we perceive there are bad guys out there that might do us harm then we’re going to be nicer to the members of our own little tribal group: our families and friends and people that are like us.”

How much we bond with “our own” when we feel threatened is also moderated by how many siblings we grew up with. In one of White’s experiments, people who had three or more siblings listened to story about an intruder entering their home or one about searching for keys in their home. People who heard the intruder story reported being much more sympathetic or unselfish toward family and friends and less agreeable towards strangers than those who heard the keys story. On the other hand, people who had only one sibling or were an only child reported they would be just as nice toward a stranger they bumped into on the street as they would towards a friend—even after they listened to the intruder story. (Because the authors used the average number of siblings to determine what was “many” versus “few” siblings in their group, the actual numbers were 3.18 siblings or more and 0.60 siblings or less.)

“One of the things that is novel and important about findings like these is that something that is seen as a basic part of your personality [such as agreeableness] actually changes in functional ways,” says co-author Adam Cohen, a social psychologist at A.S.U.

Personality traits like agreeableness and evolved responses such as group affiliation have traditionally been considered to be stable across situations. But evidence is accumulating that there is a lot of flexibility in our behavior. From an evolutionary point of view, the ability to respond differently depending on the particular social environment enables better adaptation than a strict set of behavioral “rules.”

For large tribes, circling the wagons in the face of threat is a much more effective survival technique than it is for small tribes. Living in a large tribe—or with many siblings—encourages interdependence and group cohesiveness because the cost of independence is high.

“I think what Andrew’s work is doing is marrying evolutionary approaches to culture and personality psychology, and telling us some of the ultimate reasons why people’s personalities and cultures might be different from each other in the first place,” says Cohen.

Knowing these reasons may help researchers find new ways to ameliorate intergroup conflicts. It is possible that cultures and religions that encourage large families respond to threat by banding together and ostracizing out-groups. Although empirical proof is lacking, Kenrick suggests that when negotiating with an outsized clan, the first priority is to underline your similarities. If they feel like you are one of them, you have a better chance of getting on their soft side.