For indispensable reporting on the coronavirus crisis, the election, and more, subscribe to the Mother Jones Daily newsletter.

In a 5-4 decision, the Supreme Court overturned a long-standing precedent Monday that had barred states from requiring online companies to collect and pay sales taxes, delivering a victory for cash-strapped states and brick-and-mortar retailers.

Online retailers have long enjoyed an advantage over brick-and-mortar stores because of a 1992 Supreme Court ruling in Quill v. North Dakota, which forbade states from interfering with interstate commerce by taxing companies that don’t have a physical presence within their boundaries.

In the new case, South Dakota v. Wayfair, South Dakota attempted to overturn that precedent, arguing that Quill was decided before the existence of internet commerce. (It dealt primarily with catalog sales.) The state, which argued it lost $50 million a year in sales tax, was supported by independent retailers such as bookstores that are forced to compete with online companies but whose products end up being more expensive because they must charge sales taxes. Even President Donald Trump has railed against the unfairness of online companies’ sales tax exemption.

Congress has wrestled with the issue for years, but fierce lobbying by online retail giants has prevented a legislative fix. A bipartisan group of senators filed a brief in the case supporting South Dakota’s effort to overturn the online sales tax ban, essentially acknowledging that the legislative body was too dysfunctional to fix the problem.

Supreme Court Justice Anthony Kennedy seemed sympathetic to the states’ plight, and he essentially invited the South Dakota case in 2015 in Direct Marketing Association v. Brohl. That case involved Colorado’s attempt to collect taxes from online retailers indirectly by making them report sales to the state. Online retailers sued over the scheme, and the Supreme Court allowed the case to proceed. But in a concurrence, Kennedy acknowledged the “startling revenue shortfall” suffered by the states because of the court’s Quill decision, and invited them to find a better case in which to present the issue to the high court. South Dakota took him up on the suggestion.

Even so, during oral arguments, several justices seemed lukewarm on the idea of overturning the old precedent. In particular, Chief Justice John Roberts Jr. noted that many of the largest online retailers, including Amazon and eBay, were already collecting sales taxes for the states voluntarily. He suggested that the problem may be resolving on its own, and that ultimately this was something for Congress to resolve, not the high court.

In the end, Kennedy prevailed, writing the opinion for the majority and acknowledging that even the court’s longtime precedents need to adapt to modern reality. “The Internet’s prevalence and power have changed the dynamics of the national economy,” he wrote.