In a closely watched tax case with broad implications for commerce in the digital age, a divided U.S. Supreme Court on Thursday allowed states to collect sales taxes from online retailers that don't have a have a physical presence in their borders.

By a 5-4 vote in the case South Dakota v. Wayfair, the majority, led by Justice Anthony Kennedy, overturned the court's 1992 decision in Quill v. North Dakota, which had affirmed the “physical presence” test for state sales-and-use tax collections.

“Each year the physical presence test becomes further removed from economic reality and results in significant revenue losses to the States,” Kennedy wrote. “These critiques underscore that the physical presence rule, both as first formulated and as applied today, is an incorrect interpretation of the commerce clause.”

Kennedy said the test was estimated to cost the states between $8 billion and $33 billion annually. In South Dakota alone, he said, the estimated revenue loss was $48 million to $58 million annually.

In an unusual alliance, Chief Justice John Roberts Jr., joined by justices Stephen Breyer, Sonia Sotomayor and Elena Kagan, dissented.

“E-commerce has grown into a significant and vibrant part of our national economy against the backdrop of established rules, including the physical presence rule,” Roberts said. “Any alteration to those rules with the potential to disrupt the development of such a critical segment of the economy should be undertaken by Congress.”

South Dakota and more than 40 states told the court the continuing force of the Quill decision was depriving states of billions in sales tax revenue while also giving unfair advantage to internet retailers over brick-and-mortar stores that must pay sales taxes.

“Our states are losing massive sales tax revenues that we need for education, health care and infrastructure,” South Dakota Attorney General Marty Jackley argued during oral argument. “Our small businesses on Main Street are being harmed because of the unlevel playing field created by Quill, where out-of-state remote sellers are given a price advantage.”

But Wayfair and other Internet retailers fought back, asserting that if Quill were reversed, retailers would have to comply with sales tax requirements of more than 12,000 jurisdictions nationwide as well as burdensome rules concerning retroactive tax obligations. “That complexity has only worsened over time,” said Wayfair's lawyer, George Isaacson of Brann & Isaacson in Lewiston, Maine.

“Today's decision culminates years of tireless work by the retail community to reverse a pre-internet era rule that distorts free markets and puts local brick and mortar stores at a competitive disadvantage with their online-only counterparts,” said Deborah White, general counsel to the Retail Industry Leaders Association and president of the Retail Litigation Center. “This was the right case and the right time for the Court to act, and we couldn't be more pleased with the outcome.”

During oral argument in April, some justices noted that computer software could ease the process of paying out-of-state sales taxes, and that Amazon and other retailers are already collecting sales taxes from some or all states.

Justices also discussed whether the taxation issue should be something for Congress, not the courts, to resolve, even though Congress has been weighing possible legislation—but not acting—for more than 25 years.

The Supreme Court's decision in South Dakota v. Wayfair is posted below:

Read more: