By: Jess Bravin, Brent Kendall, and Laura Stevens of the Wall Street Journal

States have the authority to make online retailers collect sales taxes, the Supreme Court ruled Thursday, a milestone marking e-commerce’s treatment as a mature player in a marketplace no longer defined by trips to the corner store or the shopping mall.

By a 5-to-4 vote, the court closed a loophole that helped fuel the early growth of internet sales, overruling a half-century of its own precedents that forbid states from requiring merchants to collect sales tax unless those sellers maintain a “physical presence” within the state’s borders.

The ruling likely will spell the end of an era in which consumers could avoid taxes by purchasing goods online instead of from local merchants.

Justice Anthony Kennedy, who suggested years ago that the precedent should be updated for the digital age, wrote for a majority that defied conventional ideological lines. Liberal Justice Ruth Bader Ginsburg joined his opinion, along with conservative Justices Clarence Thomas, Samuel Alito and Neil Gorsuch.

Justice Kennedy said the “physical presence” rule, always doubtful, had become untenable. He cited studies suggesting that the court’s own “artificial, anachronistic rule” now costs states up to $33.9 billion annually in uncollected sales taxes, sapping resources for essential public services while distorting the marketplace by advantaging remote sellers over those anchored in the community.

Because the court’s rulings freed out-of-state sellers from collecting sales taxes, the duty to pay them has fallen on consumers themselves. Few people have known of that obligation, and fewer still have complied: 96% of such taxes go uncollected, according to a California tax board estimate cited by the court.

More than 40 states, territories and the District of Columbia that rely on sales taxes had urged overruling the 1967 case that established the physical presence rule and a 1992 decision that affirmed it.

Groups representing conventional store retailers including Walmart Inc. and Target Corp. backed them. South Dakota brought the suit, seeking to require out-of-state companiesWayfair Inc., Inc. and Newegg Inc. to collect sales tax on transactions with the state’s residents. Antitax groups and retail platforms including eBay Inc. and Etsy Inc. supported the defendants.

While the justices rarely disturb their own precedents, the court no longer could stand behind an erroneous decision that “limited states’ ability to seek long-term prosperity and has prevented market participants from competing on an even playing field,” Justice Kennedy wrote.

Even the four dissenters, led by Chief Justice John Roberts, agreed that the “physical presence” rule was wrong. But with so much of the economy having grown under its influence, they said the court should leave well enough alone.

Congress, under its constitutional power to regulate interstate commerce, could at any time have altered the court’s rules, which effectively serve as a default in the face of legislative inaction. Torn between opposing commercial interests and fearful of the blame for effectively increasing costs for consumers, Congress hasn’t found the will—or consensus—to do so.

Some online retailers, such as Inc.,already collect state sales tax on products they sell directly. Others don’t—and, to Justice Kennedy’s chagrin, brag about it.

Wayfair’s advertising not only presents “an image of beautiful, peaceful homes,” but “also says that ‘one of the best things about buying through Wayfair is that we do not have to charge sales tax,’ ” Justice Kennedy wrote, calling the pitch, which since has disappeared from the Boston-based retailer’s website, “a subtle offer to assist in tax evasion.”

Nevertheless, the decision suggested states may face some limits on their collection powers. Justice Kennedy favorably noted provisions of the South Dakota law exempting small retailers and forgoing any effort to collect taxes retroactively on prior sales. The state imposes collection duties only on remote sellers that do more than $100,000 in business or at least 200 transactions a year within South Dakota.

“Many states will pick up on those details and incorporate them into their own regulatory regimes,” said Eric Citron, an attorney who represented South Dakota. He said he expected nearly every state with a sales tax to move legislation or regulations to enforce collections. “Complete compliance will become the norm within the next year or two,” he said.

Amazon originally set up its business model to avoid state sales taxes, limiting its physical presence to a handful of warehouses. But it changed strategy to build more warehouses closer to consumers as it has relied more on its Prime two-day shipping offer—and started charging sales tax on items it sells directly.

Amazon hasn’t collected the taxes for most independent merchants who sell on its platform. About $200 billion in sales originated with independent merchants selling on Amazon world-wide last year, according to Factset analyst estimates, compared with about $116 billion in direct sales by Amazon. The company declined to comment on the ruling.

Amazon has drawn sharp criticism from President Donald Trump, and the Justice Department had backed the states’ argument.

On Thursday, the president exulted. “About time! Big victory for fairness and for our country,” he said in a tweet. The Wall Street Journal reported in April that failed to collect taxes for more than 40 states, including New York, where the flagship store is in Trump Tower.

Online merchants’ stocks moved lower after the decision was released before recovering slightly. Amazon initially was down about 1% and Wayfair nearly 7%, before both recovered to close about flat. Etsy’s stock closed down 1.38% and eBay was down more than 3%.

Wayfair said it collects sales tax on some 80% of its U.S. orders and didn’t expect the decision to have “any noticeable impact on our business.”

“While we believe the court was not the ideal venue for creating this level playing field, we expect that today’s decision will bring clarity and certainty to this issue,” the company said.

Small online businesses have been using Amazon, eBay and Etsy to build their sales for years and have argued for a blanket legislative solution to prevent the high cost and burden of complying with different rules in each state.

“Now is the time for Congress to provide clear tax rules with a strong small business exemption,” an eBay spokeswoman said.

Before the court’s ruling, eBay Chief Executive Devin Wenig warned in an interview with The Wall Street Journal of an “extremely chaotic” environment if the Supreme Court handed states more authority to force companies to collect such taxes.

“Every state loves this tax because you get to tax people who can’t vote for you,” Mr. Wenig said. “You get to tax businesses that aren’t in your jurisdiction, so this is the favorite tax of every state legislature.”

Shares of retail landlords rose on the ruling. Perhaps the biggest boost came to a newly public company called Avalara Inc. that makes a type of tax-compliance software many smaller merchants may now need. Its shares finished up more than 14%.

Thursday’s opinion is likely to spur a new push for a federal law to limit states’ ability to require tax collection by small businesses and to restrain cross-border audits. This time, however, it will be internet retailers and catalog businesses seeking guardrails on state action, and they’ll have the burden of mustering majorities in Congress.

Lawmakers, however, appeared just as divided on the issue Thursday as they did before the ruling, making near-term legislative action a challenge. Like at the Supreme Court, the congressional split is not entirely ideological.

Sens. Heidi Heitkamp (D., N.D.), Richard Durbin (D., Ill) and Lamar Alexander (R., Tenn.), for example, praised the ruling as “good news” for Main Street businesses, while Reps. Bob Goodlatte (R., Va.), Jim Sensenbrenner (R., Wis.) and Anna Eshoo (D., Calif.) said the decision was a “nightmare” that would “stifle online commerce, close businesses, and ultimately harm consumers.”

“We are now really comfortable with Congress continuing its path of not acting on this issue,” said Max Behlke, director of budget and tax policy for the National Conference of State Legislatures.

Steve Delbianco, president of NetChoice, an e-commerce trade group, said Congress should act immediately to create rules for states and retailers.

“A brick-and-mortar business won’t have to comply with the differing rules of over 12,000 tax jurisdictions, or integrate costly and complex tax software into its operations,” Mr. Delbianco said in a statement. “But small web businesses will.”

Justice Kennedy saw it differently. “There is nothing unfair about requiring companies that avail themselves of the states’ benefits to bear an equal share of the burden of tax collection,” he wrote.