The Supreme Court, in a 5-4 decision, ruled Monday that public-sector unions in Illinois cannot collect fees from home health care workers who don't want to be part of a union.

The ruling is a setback for labor unions that have boosted their bargaining power -- as well as their bank balance -- in states like Illinois, by signing up thousands of in-home care workers and forcing them to fork over union dues.

The ruling, however, was limited to health care workers and not all private-sector unions. It also stopped short of overturning decades of practice that allowed public-sector unions to pass representation costs to non-members.

Justice Samuel Alito said home care workers "are different from full-fledged public employees" because they work primarily for their disabled or elderly customers and do not have most of the rights and benefits of state employees.

The decision was handed down Monday by the Supreme Court in the final session of its nine-month term. The court also ruled on a challenge by for-profit businesses, including art-and-crafts company Hobby Lobby, regarding the requirement in ObamaCare to provide free contraceptive coverage.

In the union case, plaintiff Pamela Harris serves as the primary caretaker for her son, Josh, who has a rare genetic syndrome. She receives Medicaid funds and essentially functions as a state employee.

There are about 26,000 Illinois workers who provide home care for disabled people and are paid with Medicaid funds. In 2003, Illinois passed a measure deeming the workers state employees eligible for collective bargaining.

Service Employees International Union (SEIU) Healthcare Illinois-Indiana, the union that represents publicly employed home care workers, automatically deducts membership dues from employees’ paychecks under the collective bargaining agreement it has with the state.

Harris, as well as a handful of other personal care providers, sued Illinois, demanding it stop labor unions from collecting fees from workers who refuse representation. They argue that forcing them to pay the fees violates their First Amendment rights.

Labor unions argue, though, that if Illinois is allowed to back out of its collective bargaining agreement, it would only be a matter of time before workers see their wages cut and benefits dropped.

Union leaders also fear that conservative judges across the country will use the ruling in Harris’ case to strike down laws in 26 states that currently require public-sector employees, such as teachers and police officers, to fork over dues to the unions that negotiate contracts on their behalf even if the employee doesn’t want to become a union member.

“No court case is going to stand in the way of home care workers coming together to have a strong voice for good jobs and quality home care,” SEIU President Mary Kay Henry said in a written statement following the ruling. “As a time when wages remain stagnant and income inequality is out of control, joining together in a union is the only proven way home care workers have of improving their lives and the lives of the people they care for.”

The Associated Press contributed to this report.