Public-employee unions took a hit but dodged a potentially devastating blow Monday when the Supreme Court ruled that thousands of home health-care workers in Illinois cannot be required to pay dues to cover the cost of collective bargaining.

The ruling is a setback for unions that in recent years have increased their ranks and financial prowess by organizing hundreds of thousands of home health-care workers who were required to pay dues, whether or not they chose to be members.

Now those workers can decide whether they want to pay union dues from their often meager paychecks, a change labor groups worry could cause their memberships and incomes to shrink.

Still, the court’s decision contained a silver lining for organized labor. Since the ruling covered only home health-care workers, it left in place a decades-old law permitting public-sector unions to collect dues from nonmembers to cover their bargaining costs. Had that precedent been struck down, it would have severely weakened unions overnight, making it more difficult for them to be a force both in bargaining and in politics.

Despite the narrow ruling, the conservative legal organization that helped bring the case before the court noted that the decision raised broad questions about the rationale supporting the law requiring nonmembers to pay union dues. That left the group optimistic that a broader challenge would emerge in the coming years that, if won, could truly devastate labor in this country.

“We think it is a victory,” said Patrick Semmens, vice president of the National Right to Work Legal Defense Foundation, an organization that objects to workers being forced to support unions. “It certainly didn’t close the door on taking this bigger issue on at some point in the future.”

Union officials said they hope to work with Illinois officials to devise a new model that would allow home health-care workers to elude the prohibitions laid out by the Supreme Court.

“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,” said Mary Kay Henry, president of the Service Employees International Union, whose 2.1 million members include 400,000 home health-care workers.

More than 35 percent of government workers are union members, a rate five times higher than the 6.7 percent among workers in the private sector. That disparity, coupled with the strong financial and other support most unions offer Democratic politicians, has put organized labor in the crosshairs of opponents in the courts and elsewhere. In recent years, states including Wisconsin and Michigan have enacted laws limiting the rights of unions.

The high court case focused on Illinois, one of 26 states where government workers are required to pay dues to unions that negotiate their contracts and help enforce them, whether or not they are members.

Home health-care workers in Illinois who work at the pleasure of their clients but are paid with government health-care dollars were deemed public employees in 2003 and organized as members of the SEIU. Previously, they were independent contractors; joining a union gave them leverage to bargain for better pay and benefits.

The change also presented a growth opportunity for unions. With 10,000 Americans reaching retirement age every day, the fast-expanding field of home care workers offered a promising supply of potential new members. It also guaranteed new revenue, as even workers who chose not to join a union were assessed a fee, which unions were prohibited from spending on political activity.

But a group of home care workers filed a suit in 2010 challenging the arrangement in Illinois. They said the state had violated their First Amendment rights by forcing them to be represented by a union and pay dues. Two lower courts dismissed the case before it was heard by the Supreme Court.