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...