Americans are more likely to vote for far-right or far-left politicians in areas where local manufacturing has been gutted by U.S. trade with China.

U.S. voters are undergoing an “ideological realignment” in the congressional districts most exposed to competition from Chinese imports, four leading academic economists found in a new research paper. As factories shutter, jobs disappear and local economies sputter, Americans are favoring either conservative Republicans or liberal Democrats over more centrist candidates.

America’s political polarization helps explain in part the unexpected runs of anti-establishment candidates in the 2016 presidential race.

Donald Trump, a Republican contender, has rallied voters with his populist rhetoric and tough talk against globalization. The billionaire businessman has pledged to slap a 45 percent tariff on U.S. imports from China. Sen. Bernie Sanders of Vermont, a Democratic candidate, has pledged to keep jobs in the U.S. by opposing free trade deals, including the Trans-Pacific Partnership, and by supporting small businesses.

“In retrospect, whether it’s Trump or Sanders, we should have seen it coming,” David Autor, one of the paper’s authors and a leading labor economics and trade scholar at the Massachusetts Institute of Technology, told the New York Times this week. “The China shock isn’t the sole factor, but it is something of a missing link.”

The researchers cross-referenced voting records from the 2002 and 2010 congressional elections with district-by-district patterns of job losses and other economic trends over that same period. In trade-exposed districts already in Republican hands, voters were “substantially more likely” to elect a conservative Republican, according to the research paper. On the flip side, trade-exposed districts with Democratic leaders were more likely to elect either a liberal Democrat or a conservative Republican.

In 2001, the year China joined the World Trade Organization, total U.S. manufacturing jobs averaged 16.4 million positions, U.S. Bureau of Labor Statistics seasonally adjusted data show. By 2010, manufacturing jobs fell by nearly 30 percent to 11.5 million positions as competition with China intensified and the 2008 global financial crisis continued to weaken consumer and industrial demand.

US Manufacturing Jobs The number of total U.S. manufacturing jobs, seasonally adjusted. Photo: U.S. Bureau of Labor Statistics

U.S. manufacturing has recovered slightly to 12.3 million jobs in 2015. But many towns across the United States remain shells of their former selves, with boarded-up storefronts, graveyards of abandoned factories and shrinking populations. Amid such decline, voters are reaching out for candidates who promise to infuse their communities with jobs and brighter economic prospects, the researchers said.

“Exposure to import competition is bad for centrists,” Gordon Hanson, a professor at the University of California, San Diego and one of the authors, told the Times. David Dorn of the University of Zurich and Kaveh Majlesi of Lund University in Sweden also co-authored the research paper.

“We’ve known that political polarization and income inequality track each other, but that pattern is simply a correlation,” Hanson told the newspaper. “We’ve now found a mechanism for how much economic changes create further political divisions.”

The divide has become especially prominent among unionized workers, who are increasingly inclined to support Trump and his anti-trade rhetoric, International Business Times reported last month. Some Democrats and labor officials said they worried the eccentric real estate mogul could capture a large segment of the union vote, which is historically a crucial part of the Democratic electoral coalition.

“Donald Trump is tapping into the very real and very understandable anger of working people,” Richard Trumka, the head of the AFL-CIO, the nation’s largest labor federation, said in a March speech.