One of the biggest surprises on election night occurred as Americans watched Democratic strongholds in the Rust Belt turn red. A few in particular—Wisconsin, Pennsylvania, Michigan and Ohio—were especially shocking. These states—once thriving manufacturing centers with powerful labor unions—had voted for Democratic presidents for decades. This election, they chose Trump.

It’s no coincidence that these states, with their large percentages of blue-collar workers, were also the backdrop for contentious, Republican-led battles to weaken labor unions, battles that the labor movement ultimately lost in Michigan in Wisconsin. In recent years, Republican governors in both Wisconsin and Michigan signed controversial right-to-work laws, which allow many blue-collar workers to opt out of joining unions and paying dues, while still reaping the benefits of collective bargaining for higher wages and better working conditions. This means that unions wind up with less less money and thus wield less influence to get out the vote for Democrats, the party with which they’ve long been allies.  

In Michigan, home to the influential United Auto Workers, Republican Governor Rick Snyder passed one such law in 2012 amid mass protests. In the first year after the law went into effect, union membership in the state fell by 11 percent (though it has inched up a bit since then). In 2015, Wisconsin Governor Scott Walker pushed the same type of law through with similar results. “Republicans knew this would decimate unions, and now we can see the impact,” says Erik Loomis, a labor historian at the University of Rhode Island.

Back in the 1980s, unions represented 22 percent of private-sector workers, he says. Now they represent only about 8 percent. Loomis points to two major historical shifts that inflicted major damage to the labor movement: the drying up of manufacturing jobs in the late 1970s as factories moved overseas, and more recently, Republican-led movements to pass laws restricting unionization. This year, West Virginia became the 26th state to pass right-to-work laws, which went into effect this summer.

But it’s not just right-to-work laws that have weakened the labor movement. Unions had tried to stop the impacts of globalization and automatization, Loomis says, but “they were overwhelmed by a bipartisan belief in globalized trade and nobody has taken long-term unemployment and community decline seriously.” Neither Ohio nor Pennsylvania has passed right-to-work legislation, but their industries—and the chance that they would vote Democratic—have fallen nevertheless.

The election results in Nevada reflect a stark contrast. Hillary Clinton won the state with the help of the labor movement, and in particular, with the help of Culinary Workers Union, which put on an aggressive campaign to mobilize its 57,000 members to vote for Democrats. Clinton won by a large margin in Nevada and so did the state’s Democratic Senate candidate, Catherine Cortez Masto. “The key difference is that they were able to organize working-class people to get their votes,” says Loomis. There is also another key difference: The Culinary Union is mostly made up of Latino workers in the hotel and service industry, a different demographic from the predominantly white factory workers in the Rust Belt who made up the base of the labor movement there and have since seen their jobs disappear.

As Politico notes, Clinton got less support from union households than any Democratic president since Walter Mondale in 1984—leaving her with only an 8 percent advantage over Donald Trump. In the end, it may have been a combination of a weakening labor movement and Trump’s strong anti-trade, anti-globalization message that helped him win the White House.