WASHINGTON—The Supreme Court has barred public-employee contracts requiring workers to pay union dues, dealing a severe blow to perhaps the strongest remaining redoubt of the American labor movement.

The 5-4 vote, along conservative-liberal lines, on Wednesday overruled a 1977 precedent that had fueled the growth of public-sector unionization even as representation has withered in private industry. More than one-third of public employees are unionized, compared with just 6.5% of those in the private sector, according to a January report from the Bureau of Labor Statistics.

The impact of the ruling is likely to stretch far beyond the workplace, sapping resources from unions such as the American Federation of State, County and Municipal Employees and the National Education Association that have provided funds, resources and activists largely in support of Democratic candidates. In the 2016 election cycle, public-sector unions spent $64.6 million on political activities, and 90% of that went to Democrats, according to the Center for Responsive Politics. The largest spenders were the nation’s two biggest teachers’ unions and Afscme.

Still, total spending by all labor unions, $213.3 million in the 2016 cycle, was small relative to the $3.43 billion spent by businesses. That business spending was split evenly between Democrats and Republicans.

Unions, which long have anticipated this day, have been preparing strategies to retain membership, but significant drops in support are likely.