The Supreme Court ruled Thursday that states can require out-of-state online retailers to collect sales taxes, reversing a previous high court decision that limited collections to stores with a physical presence and paving the way to more online sales taxes nationwide.

In a 5-4 decision written by Anthony Kennedy, the court ruled that that physical presence standard is "unsound and incorrect."

The ruling in South Dakota v. Wayfair, Inc., provides a major win for brick-and-mortar retailers and state governments hungry for tax revenues. The Trump administration, too, had sought greater latitude for online sales taxes, splitting with many conservatives on the issue.

Thursday's ruling defied the usual partisan lines, as justices Clarence Thomas, Ruth Bader Ginsburg, Samuel Alito, and Neil Gorsuch joined with Kennedy.

The ruling undid earlier Supreme Court precedents regarding state taxation powers, including 1992’s Quill Corp. v. North Dakota. That decision set the precedent that states could not require out-of-state sellers with no physical presence to collect sales taxes on in-state sales.

“Each year," Kennedy wrote, that ruling "becomes further removed from economic reality and results in significant revenue losses to the States.”

The intervening time has seen the rise of Internet retail, making the Quill standard the cause of heavy-duty lobbying and politicking. Traditional retailers have fought to have online sellers face the same tax collection rules they do, arguing that Internet retailers are given an price advantage by not having to collect taxes. While consumers are supposed to pay sales taxes on online purchases, most do not.

The brick-and-mortar retailers have been joined by state governments fearful of hemorrhaging tax revenue. South Dakota wrote its law as a test case for the Supreme Court.

“Retailers have been waiting for this day for more than two decades," said Matthew Shay, CEO of the National Retail Federation. "The retail industry is changing, and the Supreme Court has acted correctly in recognizing that it’s time for outdated sales tax policies to change as well. This ruling clears the way for a fair and level playing field where all retailers compete under the same sales tax rules whether they sell merchandise online, in-store or both. "

The Trump administration also favored allowing state collections on online sales taxes. Following President Trump’s comments on Twitter and elsewhere calling for Internet sales taxes, the administration argued for a broad understanding of state power to tax online sales, arguing that online stores have “virtual” presences similar to physical locations.

On the other side of the argument are Internet retailers such as Wayfair and eBay, the sales platform.

Some conservative groups also oppose allowing states to tax out-of-state retailers, on the grounds that it would allow governments to tax people who have no democratic control over them.

During oral arguments, the justices wrestled with the complexities that would ensue if they undid the Quill standard, worrying about the possibility that a handful of online giants could dominate small brick-and-mortar retailers and wondering where the constitutional threshold should be for commerce to face sales tax obligations.

Chief Justice John Roberts, joined by Stephen Breyer, Sonia Sotomayor, and Elena Kagan, dissented from the decision, writing that they would have preferred to allow Congress to resolve the issues through legislation.

Now, Congress will face pressure to act, facing a new set of ground rules.

The National Retail Federation called on Congress to pass legislation setting uniform rules for retailers across the country.

Meanwhile, conservative groups immediately pressed for a law to protect small online sellers.

"Congress must act in the American people’s best interest and pass specific legislation that protects small business and consumers from unnecessary online taxes," said Jason Pye, vice president of legislative affairs for Freedomworks.

South Dakota's specific law exempts out-of-state online sellers who engage in fewer than 200 transactions in the state. Kennedy wrote that that threshold affords "small merchants a reasonable degree of protection."

Yet the question is whether other states would set laws allowing them to capture more tax revenues from businesses with fewer connections to the states.

Oregon senator Ron Wyden, the top Democrat on the Finance Committee, called the ruling a "catastrophic decision," and said that it would give "the green light for states to establish an underground, nationwide, privatized tax-collecting bureaucracy."

Retailers for years have sought legislation from Congress allowing for online sales tax collections. Those proposals, though, have split the GOP majorities.

Now it is will be their opponents pushing for federal legislation to limit states' ability to tax beyond their borders.

"Congress must now act to contain the fallout of this case," said Andrew Moylan, executive director of the National Taxpayers Union Foundation, which favored keeping the physical presence standard.