Since the November election, in which U.S. President Barack Obama won huge majorities among minority voters, it’s been taken as gospel that the Republican Party must, for its own survival, seek to appeal to those groups by moving to the left on topics such as immigration reform. But as the nation becomes more diverse, the demographic shift can cut the other way, too: Some Democratic voters are likely to move to the right.

It’s assumed that, as the United States becomes increasingly nonwhite, white Democrats will continue to support the party. But a substantial amount of social-science evidence suggests a different conclusion: As the U.S. becomes more racially and ethnically diverse, liberal whites might start leaning Republican.

Consider a straightforward experiment I conducted last year: Over two weeks, I sent pairs of Latino men in their 20s to ride commuter trains in the greater Boston area, often cited as one of the nation’s most liberal regions. These people were not asked to do anything out of the ordinary, just to wait for the train and ride it. The pairs I sent were native Spanish speakers, so when they spoke to each other, it was probably in Spanish.

To gauge other riders’ attitudes about Latinos, I surveyed them before the experiment and two weeks into the tests. In each case, the trains and times were randomly selected and were later compared with a control group of riders on different trains. These trains originated in communities with very few Latino residents, and the men I sent to ride the trains were often the only Latinos at those stations. In this sense, the experiment was testing how people react when a very small group of Latinos moves to a new community.

The results were clear. After coming into contact, for just minutes each day, with two more Latinos than they would otherwise see or interact with, the riders, who were mostly white and liberal, were sharply more opposed to allowing more immigrants into the country and favored returning the children of illegal immigrants to their parents’ home country.

It was a stark shift from their pre-experiment interviews, during which they expressed more neutral attitudes.

Political scientists, economists, sociologists and psychologists have long noted that, under most circumstances, when people from different ethnic, racial and religious groups come into new contact, conflict ensues. Just look at the battles over busing students from different neighborhoods into public schools in the 1960s and ’70s. And those conflicts often change the way people vote.

In the 1930s, political scientist V.O. Key found evidence that, in Southern counties with large numbers of blacks, white voters were politically mobilized: They voted more than whites in neighboring counties and supported candidates espousing discriminatory views in greater numbers. A similar trend recurred a generation later, when liberal Illinois Democtrat Sen. Paul Douglas lost his 1966 re-election bid, in large part because of votes cast by whites living in parts of Chicago that had seen an influx of blacks.

In a more recent example, the city of Chicago began a massive effort in 2000 to overhaul its public housing. Large and notorious housing projects, such as Cabrini-Green, were demolished, and their residents were relocated. More than 99 percent of the relocated residents were black. The outcome of the effort was the reverse of my experiment in Boston — rather than coming into contact, groups were separated.

Did that separation result in more liberal political views? Voting patterns among white residents living near these projects before and after their demolition showed that it did. After their black neighbors left, fewer white residents turned out to vote, and voters became less likely to choose Republican candidates, whom they had previously supported at higher levels than had residents in other parts of the city. It seems that the contact with blacks had politically mobilized whites in Chicago, similar to how Southern whites were mobilized in the 1930s.

To explore whether there was a similar effect among minority voters, in 2008 I conducted an experiment in which I sent a letter to black voters just before an election in Los Angeles. The content of the letter was simple: It reminded people to vote and included a map noting how often people on their block voted compared with a nearby block. In some randomly selected cases, the comparison block consisted of black residents; in others, it was largely Latino. When the letter pointed to a majority-Latino block, blacks were significantly more likely to vote, suggesting that they were concerned about political competition with Latinos — even though both groups vote overwhelmingly for Democrats.

In that same year, I examined the voting of Latinos in Los Angeles and found that those who lived near predominantly black neighborhoods were far less likely to vote for Obama than Latinos who lived farther away — suggesting that contact with their black neighbors may have prompted them to vote against an black candidate.

As different groups come into contact, people often have adverse reactions, and this can cause them to vote for a party that represents opposition to other groups. In today’s electoral landscape, that might mean white Democrats would be more willing to vote Republican. There is some evidence that when most people vote against their party identification they return to their regular partisan identity within an election or so. However, if people make that switch during their impressionable years, in their teens or 20s, it can last a long time. And if they become familiar with members of the other group on a personal level, then the initial aversion might diminish. For example, this might be why attitudes about same-sex marriage are changing — as more people come to know gay friends, neighbors, co-workers or family members.

Of course, people might change the way they vote for reasons other than the race or ethnicity of their neighbors, such as a change in their job or the birth of a child. However, these experiments tell us that, all else equal, contact between different groups leads to more conservative voting.

None of these findings bode well for Democrats. As ethnic groups mix, voters become more exclusionary and tend to vote for more racially conservative candidates — which may make it more difficult to maintain a diverse Democratic Party and could tilt the field in favor of Republicans.

But such changes are not inevitable.

Just as demographic shifts do not guarantee a Democratic majority, it is not certain that interaction between groups will hurt Democrats. Social scientists have identified a host of conditions that foster political harmony between groups, including economic equality and common goals, such as being part of the same team in the workplace, school or the military. These are conditions that liberals typically favor through their legislative agenda.

For example, a progressive tax code and liberal social spending are designed to promote economic equality. And immigration reform proposals, such as the Dream Act, are designed to more fully integrate institutions such as colleges and the military. The recognition that liberals’ policies cannot only establish their ideological goals but also help maintain their political majority should give Democrats greater urgency in their legislative efforts to promote equality.

Ryan D. Enos is an assistant professor of government at Harvard University.