Protesters against the TPP display signs as vice presidential candidate Tim Kaine addresses the Democratic National Convention in Philadelphia on Wednesday, July 27, 2016. (Photo by Michael Robinson Chavez/The Washington Post)

Economic globalization hasn’t won any popularity contests this summer. After 25 million primary voters supported the protectionist rhetoric of Bernie Sanders and Donald Trump, both parties’ national conventions featured strident opposition to international trade. When Democrats met in Philadelphia last month, attacks on the Obama administration’s big trade deal with countries of the Pacific Rim, the Trans-Pacific Partnership (or TPP), led some observers to pronounce it all but dead. At the Republican convention in Cleveland, Trump declared that, “Americanism, not globalism, will be our credo,” attacking NAFTA (the 1994 North American Free Trade Agreement) and a string of trade agreements negotiated since.

Meanwhile, a majority of British voters chose to leave the European Union, rejecting decades of economic integration. The morning after the Brexit vote, business leaders, political pundits, and experts of all kinds were in shock. The economic costs of leaving the E.U. were too significant; “sober” economic reasoning, many had believed, would surely prevail.

But social science reveals that rational economic calculus has some competitors in shaping citizens’ opinions on globalization.

Nationalism, prejudice, and protectionism

If you listen to the rhetoric of recent globalization debates, you’ll hear another major influence. Many observers have noted that Donald Trump’s anti-trade language is decidedly “us versus them.” In Britain, the “leave” movement’s campaign against economic openness was infused with anti-foreign sentiment.

A series of studies by both economists and political scientists confirms this link between nationalistic sentiment and opposition to global markets. Negative attitudes toward “out-groups” — ethnocentrism, generalized prejudice and chauvinistic nationalism, for example — are some of the strongest predictors of protectionism in individuals. Several of these studies suggest that attitudes toward outsiders affect opinion about globalization more than economic self-interest does.

This research focuses mainly on public opinion toward trade — the flow of goods, not of people. The connection between protectionist sentiment and negative out-group attitudes has been made more obvious this year, as both Trump and many pro-Brexit campaigners have also railed against migrants. But even with no discussion of immigration, those who are hesitant about outsiders are far more likely to oppose open markets than those with a more welcoming outlook.

That makes sense, considering what we know from psychology and behavioral economics. In their Nobel Prize-winning work, psychologists Daniel Kahneman and Amos Tversky argued that the human mind is lazy: It relies on shortcuts to bypass the effort required by deliberate reasoning, unconsciously turning complex decisions into quick, intuitive judgments.

When it comes to foreign trade, the “foreign” aspect of the issue presents the most prevalent mental shortcut. International trade involves dealing with “others.” Research on globalization opinion suggests that the average individual’s opinion on trade comes not from rational (and mentally demanding) assessments of costs and benefits, but gut-level decisions guided by attitudes toward out-groups and foreignness.

This research is consistent with findings from a recent study of Republican voters. The study, based on a Gallup survey of 87,000 Americans, finds no connection between an individual’s risk of economic loss to trade competition and his or her support for Trump’s economic nationalism. Rather, those who support Trump and his protectionist stance tend to have little contact with immigrants and racial minorities. That insularity is linked to negative attitudes toward outsiders.

But there are other sources of protectionist opinion as well. When President Obama traveled to Hanover, Germany, in April to promote his trade deal with Europe, the Transatlantic Trade and Investment Partnership (or TTIP), thousands of demonstrators gathered to oppose the agreement. Across Europe, voters worry about fairness and predatory corporations. They are questioning the secrecy of the TTIP’s negotiation, and protesting what they believe will be the resulting erosion of consumer protection and environmental standards.

On our side of the Atlantic, similar considerations — concerns over economic inequality, in particular — have been a key part of Bernie Sanders’s protectionist message. The villains in his story are not foreigners, but corporate interests perpetuating inequality at home and abroad.

We have less research on these aspects of globalization opinion. In a preliminary study, however, I find that among the most liberal Americans, trade opinion is strongly tied to beliefs about the impact of globalization on the poorest segments of society.

Disentangling human motivations is a complicated business, especially when motives tied to identity or values appear to overlap with economic interests. It is certainly no coincidence that anti-globalization messages have been resonating deeply with voters who feel personally cheated by open markets. But pure economic reasoning rarely tells the whole story.

Shahrzad Sabet is a postdoctoral fellow at Harvard University’s Weatherhead Center for International Affairs.