Donald Trump placed second in Monday's Iowa caucuses, with 24 percent of the vote. When he announced his campaign nearly a year ago, no analyst expected him to do so well. The winner was Sen. Ted Cruz (R-Tex.), another firebrand who has done better than many anticipated.

The success of both candidates reflects a shift among Republicans that began 15 years ago. In that time, Republicans have completely reversed their views on immigration, creating the conditions for a candidate, such as Trump, to run on a nativist platform.

Americans, in general, have become much more tolerant of immigrants in recent decades. Until recently, that was true of Republicans as well, and voters in both parties were largely in agreement on the question. Now, however, Republicans have become more conservative in their views on immigration, and the issue has become a bitterly partisan one, according to survey data provided to Wonkblog by the Pew Research Center.

Regardless of party, Americans used to be much more hostile toward immigrants. As recently as 1994, 63 percent of all Americans viewed immigrants as "a burden" to society, according to a poll Pew conducted that year. Today, the share of those who see immigrants that way is just 38 percent.

Most of the shift occurred during the Clinton administration. The economy was booming in those years, and so was the population of immigrants. According to the Census, the foreign-born population increased 57 percent between 1990 and 2000, from 19.8 million to 31.1 million.

Perhaps as a result of these trends, Americans adopted more tolerant views of immigrants. The share describing immigrants as a burden declined from 63 percent of both Democrats and Republicans in 1994 to 38 percent of Republicans and 35 percent of Democrats in 2000.

Among Democrats, the figure continued to decline. Today, just a quarter view immigrants as a burden. The decline among Democrats isn't a result of the party's increasing diversity. White Democrats are no more conservative on the question than Democrats of color, according to Pew.

In the new millennium, meanwhile, Republicans' attitudes toward immigrants have hardened. In Pew's poll in May, once again, 63 percent of Republicans agreed that immigrants were a burden.

The Republican Party's change of heart is part of its gradual shift toward populism on a range of issues. Thomas Mann, a scholar at the Brookings Institution, traced the origins of Trump's success in particular to the tea party; the Contract With America promulgated by then-Rep. Newt Gingrich (R-Ga.), the former speaker of the House, in 1994; and to Barry Goldwater's nomination in 1964.

"Trump didn't create any of this," Mann said. "He's simply riding it in a very clever way, using his celebrity."

In particular, Trump saw an opening on immigration — an issue that surveys suggest is deeply important to his voters. Polls suggest that immigration is the main concern that unites Trump's supporters, who have a range of views on other issues and belong to many different factions in the conservative coalition, including both evangelical and secular voters.

In the most recent national poll by The Washington Post and ABC News, Trump had the support of 37 percent of registered Republicans and those leaning toward the Republican Party. Among those who strongly believed that immigrants weaken U.S. society, however, a majority supported Trump.

As for Cruz, he once supported limited legal status for undocumented immigrants but has since shifted to the right on this question. Also, he's arguably benefited from the fact that Sen. Marco Rubio (R-Fla.), Cruz's main rival besides Trump, at one point supported granting citizenship to those immigrants — a position that has become unpopular with GOP primary voters.

Norm Ornstein, a scholar at the American Enterprise Institute, called immigration "the be-all and end-all issue" for many Republican voters.

"It becomes the symbol for where you are — where you are in the culture wars, where you are in sticking it to the establishment, where you are in being sensitive to the concerns of white, working-class voters," he said.

He quoted Ann Coulter, the conservative commentator, who has made clear how important immigration is to her. "I don't care if Trump wants to perform abortions in White House," she wrote online after Trump released a white paper on immigration.

Ornstein also pointed to the defeat of Eric Cantor at the hands of a political neophyte, Rep. David Brat (R-Va.). The former Republican majority leader's loss took analysts by surprise.

"What's the issue?" Ornstein asked. "As much as anything, it's immigration."

Trump's trail had already been blazed by other candidates. In 2012, former senator Rick Santorum (R-Pa.) won primaries in 11 states, running in part on his opposition to immigration. In the GOP primary four years earlier, former representative Tom Tancredo (R-Colo.) briefly ran on a platform of restricting immigration. Although that campaign went nowhere, Tancredo would later run as a third-party candidate in Colorado's gubernatorial election in 2010 and win 37 percent of the vote.

The precedent of that election in Colorado — in which a third-party candidate split the conservative vote, handing the election to a Democrat — represents a worst-case scenario for the Republican establishment today. Trump has suggested that if he doesn't win the GOP nod, he might run against the eventual nominee in the general election.

Another opponent of immigration, Pat Buchanan, won the GOP primary in New Hampshire 20 years ago, back in 1996. The party is more conservative on the question of immigration now than it was in 1996 — and it's even more conservative than it was just four years ago, when Santorum and Mitt Romney contested the GOP primary for months. At that time, just under half of Republicans viewed immigrants as a burden to American society.

Of course, Trump's personal qualities make him uniquely appealing to Republican voters who doubt immigration's benefits, Mann said.

"It's chutzpah. It's brashness. It's arrogance," Mann said. "That's the appeal." The subdued Santorum, for example, is running again this cycle but has received comparatively little attention from voters or the media.

Mann said the Republican establishment — which is taking little consolation from the victory of Cruz in Iowa on Monday — partly has itself to blame for the shift in attitudes among the rank and file.

The opinion makers at Fox News gave air time to otherwise marginal figures, such as Coulter and Glenn Beck, the talk-radio host, Mann argued. Meanwhile, he said, GOP congressional leaders deployed the rhetoric of the tea party when it suited them.

Those decisions might have hardened anti-immigration attitudes among Republicans while bringing sympathetic Democrats and independents into the Republican fold, creating the large bloc of voters that Trump is now exploiting.

"They tried to stir up right-wing populism and use it as a basis for gaining majority status in Congress," Mann said. "It's come back to haunt them."

Marc Hetherington, a political scientist at Vanderbilt University, agreed. He noted that those same voters are making it more difficult for candidates, such as Rubio, with more moderate views on the question of immigration to win the election.

"Establishment Republicans want to do something different on immigration to try to attract Latino voters," he said. "What has happened is, they've, over the years, developed this base of people who are not real open to difference."