Here’s a surprise: During President Donald Trump’s campaign and first years in office — when he branded Mexican immigrants “rapists,” sought to ban Muslims from entering the country, and at first declined to renounce a former KKK leader — white Americans’ prejudice toward Latinos and African Americans declined.

That’s the conclusion of a new study by University of Pennsylvania scholars, whose research suggests limits on the ability of racially charged and racist rhetoric to heighten prejudice among whites.

The research also indicated that prejudice is not fixed: Its levels can rise and fall like the liquid in a thermometer, responding to political policies and speech.

Daniel Hopkins, a professor of political science, and Samantha Washington, a bachelor’s degree candidate, set out to see if Trump’s rhetoric led white Americans to express more prejudiced views of African Americans or Latinos.

“Prejudice takes a variety of forms in different places at different times,” Hopkins said in an interview. “But a lot of white Americans are not listening to Trump’s rhetoric uncritically. There are many, many millions of white Americans who view Trump’s rhetoric as racist.”

They reviewed “expressed prejudice,” which can be measured when people respond to surveys or polling. Declines occurred in both major parties but were more pronounced among Democrats.

Hopkins was surprised by the results, but also knew that there’s “a longstanding tradition in political science that when the president moves in one direction, the public moves in the other direction.”

The scholars relied on nationally representative surveys of some 20,000 people between 2008 and 2018. They also considered earlier work that assessed white respondents’ beliefs in stereotypes, by asking them to rate African Americans and Latinos on work ethic and trustworthiness.

Before 2016, the authors said, presidential candidates who sought to harness animus toward African Americans or other racial groups did so through implicit clues, targeted toward certain audiences. Trump broke from that, such as declaring there were “very fine people on both sides” of a violent “Unite the Right” confrontation between white supremacists and protesters in Charlottesville, Va. One woman was killed and dozens of people injured when a neo-Nazi rammed his car into the crowd.

Many Americans believe that racist rhetoric from a president can influence behavior and attitudes.

In a 2018 survey by the Quinnipiac University Polling Institute, 54 percent agreed that Trump had emboldened those who hold racist beliefs. Moreover, 2017 saw an increase in hate crimes, a rise that some linked to Trump’s rhetoric, the authors said. But criminal acts are likely to reflect changing behaviors among a small subset of highly prejudiced Americans, the study noted.

The number of hate-crime incidents reported to the FBI increased about 17 percent in 2017 as compared with the previous year, according to the Uniform Crime Reporting Program. Law enforcement agencies reported 7,175 hate crimes, up from 6,121 in 2016.

The researchers began with an assumption that prejudice is typically a stable tendency, acquired early in life. They wondered if Trump’s candidacy, speech, and policy positions on racial issues influenced white Americans’ prejudice.

They questioned whether the president may have normalized those views, essentially authorizing white Americans to more openly express prejudice. They also wondered if Trump would influence Americans in his role as an opinion leader, as some citizens adopt positions advocated by political elites, especially if those elites share the same political orientation, the study said.

“Our findings contradict both hypotheses,” the authors wrote, “as we primarily found declining prejudice and racial resentment, and certainly no increases.”

The United States is big and diverse, Hopkins noted, and some of Trump’s comments can land in different places with different impacts. To the minority who hold extreme, racist views, the rhetoric could be affirming and mobilizing.

But “it doesn’t mean the average American goes in that direction,” Hopkins said.