The U.S. Supreme Court gave states broad authority to require online retailers to collect sales taxes.

The court overturned a longstanding rule that states can collect sales taxes only on transactions if the retailer has a “brick-and-mortar” presence in that state. The decision could allow more states to impose sales taxes on companies that operate entirely online.

The justices did not specify what types of exceptions states may impose to limit the burden on small businesses.

The vote was a slim 5-4 decision, with Justice Kennedy writing for the majority together with Justices Clarence Thomas, Ruth Bader Ginsburg, Samuel Alito and Neil Gorsuch.

“The internet’s prevalence and power have changed the dynamics of the national economy,” Kennedy wrote. “This expansion has also increased the revenue shortfall faced by states seeking to collect their sales and use taxes.”

Chief Justice John Roberts dissented, saying the decision should be left to Congress, and was joined by Justices Stephen Breyer, Sonia Sotomayor and Elena Kagan.

“The burden will fall disproportionately on small businesses,” Roberts said. “The court’s decision today will surely have the effect of dampening opportunities for commerce in a broad range of new markets.”

Internet retailers have argued that allowing every state to collect taxes on online sales would cause confusion and unreasonable burdens in today’s online-heavy retail economy.

More than 40 states had asked the high court to overrule two, decades-old Supreme Court decisions that they said cost them billions of dollars in lost revenue annually. Customers were generally responsible for paying the sales tax on items bought online to the state themselves if they weren’t charged it, but most didn’t realize they owed it and few paid.

The ruling is also a win for large retailers, who argued the physical presence rule was unfair. Large retailers, including Apple, Macy’s, Target and Walmart, which have brick-and-mortar stores nationwide, already generally collect sales tax from their customers who buy online. That’s because they typically have a physical store in whatever state the purchase is being shipped to. Amazon.com, with its network of warehouses, also collects sales tax in every state that charges it, though third party sellers who use the site to sell goods don’t have to.