Correction: An earlier version of this editorial incorrectly identified Robert C. Post. He is a professor at Yale Law School. This version has been updated.

Light from the setting sun shines on the Supreme Court in Washington on Jan. 20. (Joshua Roberts/Reuters)

ON FEB. 26, the Supreme Court hears arguments in the most important labor case of the 21st century to date, Janus v. AFSCME. At issue are rules in 22 states requiring public employees to pay “agency fees” to cover the collective-bargaining costs of unions that represent them, even if the employees are not members of the union. If the court voids those laws, public-sector unions and the (usually Democratic) politicians they support could suffer a big financial hit.

Small wonder Republicans are rooting for opponents of agency fees. The constitutional claim is that the laws violate the First Amendment. Even if agency fees ostensibly fund only collective bargaining, when the bargaining is with states and cities it necessarily affects the size and cost of government, which are questions of public policy. That amounts to forced adherence to a cause that is not necessarily your own, the argument goes, and so agency fees must be disallowed, notwithstanding the court’s ruling four decades ago upholding them.

We have our misgivings about the costs and inefficiency public-sector unions sometimes create. Even so, the court should not take the drastic step of overturning established precedent, for two reasons. First, there is an independent value in legal stability; lawyers call it stare decisis. And second, this is indeed an inherently partisan political issue, which should be decided state by state, through the people’s elected representatives, not once and for all, by unelected justices. Yet recent trends at the court suggest that it will indeed take this opportunity to impose a nationwide ban on mandatory dues in the public sector. A similar case ended in a 4-4 tie after Justice Antonin Scalia’s death in 2016. With President Trump’s appointee, Neil M. Gorsuch, replacing him, a 5-4 vote against the unions is possible.

There is a middle way — one that could preserve precedent while addressing employees’ legitimate concerns about involuntarily funding political causes. Law professors Charles Fried of Harvard University (a former solicitor general of the United States) and Robert C. Post, of Yale Law School, have sketched this elegant solution in a friend-of-the-court brief, drafted for them by another former solicitor general, Seth P. Waxman. They propose that current law be reformed to make the agency fee a genuinely meaningful opt-out. Since the court’s 1977 decision, unions have been able to define almost everything they do — annual conventions, in-house publications — as somehow related to collective bargaining. However, the court could clarify that agency fees may be used to pay only for a union’s collective-bargaining duties as narrowly defined by state law. This would impose some objectivity and consistency on standards that unions have heretofore been able to game.

In a 1991 case, four justices — one short of a majority — signed opinions favoring such a solution. The four included Justice Anthony M. Kennedy, who is still on the court, and Mr. Gorsuch’s predecessor, Antonin Scalia. That path is still open to the justices, if they want to maximize individual freedom while minimizing legal instability.