It’s happened: After promises of strict immigration measures to halt the flow of visitors from Muslim-majority countries on the campaign trail, President Donald Trump has signed an executive order for a 90-day ban on entries from seven countries (which also includes a 120-day ban on refugees).

How did we get here? The short answer: fear.

Fear of refugees isn’t logical. It’s emotional. And that’s why it’s so powerful.

After the Paris terror attacks in 2015 and the Brussels attacks last year, Trump called for banning travel from Muslim-majority countries. And people at his rallies cheered. In March, after the Brussels attacks, a Morning Consult poll found 71 percent of Republican voters supported a “Muslim ban.”

Fearing Muslim immigrants or Syrian refugees is not logical — you’re more likely to be killed in an automobile crash or by your own clothing than by a Muslim terrorist. Rather, it’s a deeply encoded, emotional reaction that can easily be stoked by politicians.

Here are the top lessons I’ve learned from researchers of intergroup conflict about where our fear of the “other” comes from — and what we can do about it.

Lesson 1: Fearing outsiders is one of our oldest, built-in psychological tendencies.

There’s a reason every country with immigration has pockets of xenophobia. It’s our instinct to be distrustful of those whom we perceive as being "them" rather than “us.” In prehistoric times, this is what kept us safe. In the modern age, it’s what nudges us toward bigotry.

In lab experiments, it’s shockingly easy to pit people against one another. Many experiments start with randomly assigning people arbitrary teams.

"Once you trip this wire, this trigger, this cue, that you are a part of ‘us versus them,’ it’s almost like the whole brain become re-coordinated in how it views people," Jay Van Bavel, an NYU psychologist, told me in 2013. He often just uses "red" teams and "blue" teams for his experiments. Once on a team, participants immediately start showing bias toward their teammates. They’ll like their own teammates better. They’ll spend more time looking at their faces. They’re more likely to remember them.

Lesson 2: When we begin to fear outsiders, we dehumanize them

You can think of human psychology as a series of evolutionarily coded computer programs. These programs tell us how to react to new situations. When we see a baby, we want to pinch its cheeks. When we see a threatening stranger, we either want to fight them or flee from them.

Fearing others changes the way we perceive them. In experiments, this plays out in very literal and disturbing ways: In some experiments, psychologists can get participants to rate “outsiders” as having fewer human qualities.

"It’s what we call an over-exclusion bias," Mina Cikara, a Harvard psychologist who studies intergroup conflict, said in an interview last year.

When you start fearing others, she says, "your circle of who you counted as friends is going to shrink. And that means those people outside of the bounds get less empathy, get fewer resources."

It also means you become more vigilant and obsessed with marking who is an insider and who is not. "You want to draw those boundaries brighter, so you don’t make any mistakes about who you want to share your resources with or who you want to trust," she says.

This fear can then be compounded by in-group pride. “People who empathize more with their own groups tend to be more aggressive toward the out group," she says.

Lesson 3: When we fear outsiders, our brains exaggerate their threat

Van Bavel and his colleague Y. Jenny Xiao illustrated this concept nicely in a 2012 paper.

The test was simple: The researchers asked participants to estimate the straight-line distance from New York to Mexico City. Participants who expressed more animosity toward Mexican immigrants rated Mexico City as being several hundred miles closer to New York than people who felt less threatened. Since then, Van Bavel has found data that shows if people think the wall between the countries is secure, the effect goes away.

Lesson 4: Anecdotes that instill fear of outsiders are much, much stickier than facts and figures

Our brains are built to be vigilant. We’re constantly on the lookout for threats. That’s why stories about immigrants committing crimes, stories about neighbors losing jobs to immigrants, and assertions that immigrants aren’t loyal to their adopted countries, are all extremely powerful (regardless of whether they’re true).

"Once you can get that one story out there, it’s enough to start the cycle of people thinking this way and changing how people think about these out-groups," Cikara says. "People are very sensitive to anecdotes, more than they are to abstract representations of data."

Our minds have evolved to think in mental shortcuts — heuristics — but in the modern age, they can lead us astray.

Lesson 5: No one is immune from fearing the threat of outsiders

Multiple studies find when most white people are reminded that minorities will eventually be the majority, they begin to feel less warm toward members of other races.

Demographic change, researchers explain, is a source of threat that activates zero-sum thinking about race. If minorities are on the rise, the logic goes, then the majority must be losing out.

“People who think of themselves as not prejudiced (and liberal) demonstrate these threat effects,” Jennifer Richeson, a leading researcher on racial bias, says.

A more recent experiment showed that this reminder increased support for Trump. Which doesn’t mean all white people harbor extreme racial animus. It means fear is an all-too-easy button to for politicians to press. We fear, unthinkingly. It directs our actions. And it nudges us to believe the person who says he will vanquish our fears.

Lesson 6: It is possible to teach people to turn fear into something more positive

The negative reaction to refugees is more emotional than rational. And psychologists say it's unlikely to be countered by statistics or logical counterarguments. To change people's minds, either the negative emotions ("refugees are dangerous") need to be turned down or more positive emotions ("refugees are human beings like us and need help") need to be turned up.

Cikara singles out an intriguing experiment published in the journal Psychological Science that demonstrates it's possible to teach people to downplay negative emotions in us-versus-them decision-making.

For that study, Israeli researchers taught half of their participants a technique called cognitive reappraisal — basically a method to challenge your negative emotions, question how they originate, and then watch them dissipate among that meta introspection. All the participants were then instructed to look through materials designed to get them angry. A week after the training, all the participants were asked questions about the Israeli-Palestinian conflict. "What [the authors] found was that those who had practiced emotion regulation ... actually preferred less hostile and more diplomatic approaches," Cikara says.

Getting American politicians into cognitive reapprasial classes seems unlikely. But there is another approach. Charities have long understood the "identifiable victim effect," which suggests that images of singular victims are easier to empathize with than statistics, even when those statistics are astronomical.

It’s fighting emotional anecdotes with emotional anecdotes.

"This is why pictures and stories can be so powerful," Deborah Small, a professor of marketing and psychology at the University of Pennsylvania, told me in 2015. "Identifying and telling the stories of more innocent refugees could make the victim’s case more moving."

Final lesson: The boundaries of who we see as “us” and “them” are flexible

Our brains love seeing the world in terms of "us versus them," but there’s nothing in our brains that defines who "they" are. Experiments often put people into arbitrary teams. So do societies.

In 2013, Van Bavel told me about a trick that sounded so simple and hopeful. Sometimes he’ll switch a red-team participant to the blue team and vice versa. "We say, 'Listen, there's been a mistake, you're actually on the other team,'" he told me then. "And the moment we do, we completely reverse their empathy. Suddenly they care about everybody who is in their new in-group."

That might be simple in the lab, but in the real world, these feelings are more deeply entrenched. But even in the real world, experimenters are showing there are ways to reduce bias.

Last April, I reported on an experiment that showed with just the right dose of empathy, canvassers could change voters’ mind on transgender rights issues. "Two decades of opinion change took place during a 10-minute conversation, and it persisted for at least three months — that's a big effect," Josh Kalla, one of the co-authors, told me. All it took was a conversation where the voter was asked to put themselves in a transgender person’s shoes.

That type of outreach is difficult, but not impossible.