WASHINGTON (CBS) — The Supreme Court says states can force online shoppers to pay sales tax, clearing the way for major changes in the world of e-commerce.

The 5-4 ruling Thursday is a win for states, who said they were losing out on billions of dollars annually under two decades-old Supreme Court decisions that affected online sales tax collection.

The high court ruled Thursday to overturn those decisions. “The Internet’s prevalence and power have changed the dynamics of the national economy,” the court said in its decision in the case, South Dakota v. Wayfair.

Under the previous law, some companies did not collect sales tax on every online purchase. Businesses had to collect sales tax only when shipping products to a state where they had a physical presence, such as a warehouse or office. Otherwise, they didn’t have to collect the state’s sales tax.

Customers were generally supposed to pay the tax to the state themselves if they were not charged by the merchant, but the vast majority did not.

South Dakota’s attorney general, Marty Jackley, said businesses will now have tax fairness and a level playing field. South Dakota has no state income tax and so depends heavily on sales taxes.

The decision has major implications for online retailers, including Amazon, a large part of whose business consists of sales on Amazon Marketplace from other merchants. Currently Amazon collect sales tax on Marketplace purchases in just two states, Washington and Pennsylvania. Marketplace sales make up as much as one-third of Amazon’s revenue, by some estimates.

Wayfair stock was down 2.5 percent in morning trading, while shares of online craft marketplace Etsy dropped more than 3 percent. Amazon nudged down half a percentage point.

© 2018 CBS Interactive Inc. All Rights Reserved. This material may not be published, broadcast, rewritten, or redistributed. The Associated Press contributed to this report.