WASHINGTON – The Supreme Court opened the door Monday for iPhone users to sue Apple over excessive prices on its exclusive App Store.

Associate Justice Brett Kavanaugh, the court's newest member, wrote the 5-4 antitrust opinion and was joined by the court's four liberal justices. The other four conservatives dissented.

The question before the court was whether consumers' beef over prices is with Apple directly or the app developers who pass along the tech giant's 30 percent commission, as well as its rule that prices end in .99.

"Our cases have consistently stated that direct purchasers from alleged antitrust violators may maintain a suit against the antitrust violators," Kavanaugh wrote.

"Ever since Congress overwhelmingly passed and President Benjamin Harrison signed the Sherman Act in 1890, protecting consumers from monopoly prices has been the central concern of antitrust," he said. "That is why we have antitrust law."

The ruling theoretically could affect millions of iPhone app purchasers, but it's not clear how many would qualify as plaintiffs. It's also not clear how the law's triple damages for antitrust violations would be apportioned if Apple loses.

President Donald Trump's other high court nominee, Associate Justice Neil Gorsuch, wrote the dissent. He said app developers, not purchasers, have the more legitimate claim against the tech giant.

"If the commission is in fact a monopolistic overcharge, the developers are the parties who are directly injured by it," Gorsuch wrote. "Plaintiffs can be injured only if the developers are able and choose to pass on the overcharge to them in the form of higher app prices that the developers alone control."

Associate Justice Ruth Bader Ginsburg, the senior justice in the majority, presumably chose Kavanaugh to write the opinion. He noted from the bench that after more than a decade, iPhone apps now let iPhone owners watch videos, order food, donate to charities and more.

"'There's an app for that' has become part of the 21st-century American lexicon," Kavanaugh said.

Apple released a statement in which the company expressed confidence it eventually will prevaile. The App Store, it said, "is not a monopoly by any metric."

"Developers set the price they want to charge for their app, and Apple has no role in that," it said. "The vast majority of apps on the App Store are free, and Apple gets nothing from them. The only instance where Apple shares in revenue is if the developer chooses to sell digital services through the App Store."

At oral argument in November, the court's four liberal justices clearly were skeptical of Apple's monopoly.

"It just seems to me that when you're looking at the relationship between the consumer and Apple, that there is only one step," Associate Justice Elena Kagan said, referring to the way iPhone users buy apps.

More from the court:Strict state anti-abortion laws aimed at Supreme Court, justices not eager to consider them

David Frederick, the lawyer representing consumers, agreed that "there's no middleman in this particular transaction," as Apple had maintained. The company's antitrust violation, he said, was the App Store itself.

But company attorney Daniel Wall contended that under Supreme Court precedent, the app developers are the ones setting prices charged consumers. If the commission affects those prices, he said, that's between Apple and the developers.

In his ruling, Kavanaugh rejected that argument. He said it would allow lawsuits when retailers mark up manufacturers' prices but not when manufacturers charge commissions to retailers, though the result may be the same higher price.

Apple also claimed that calculating damages would be complicated, but Kavanaugh said that should not be a "get-out-of-court-free card for monopolistic retailers."

A federal district judge initially ruled in Apple's favor. But a panel of the U.S. Court of Appeals for the 9th Circuit in San Francisco overruled that decision last year and held that consumers were direct purchasers of iPhone apps. The Supreme Court's ruling upheld that verdict.

Chief Justice John Roberts, who joined the dissent, had warned during oral argument that both consumers and app developers should not be able to sue the company for the same alleged violation. Gorsuch said only one of those groups can be paying what he called the "monopoly rent."

But Kagan said the two groups suffer different losses – consumers through higher prices and developers through reduced sales.

The company heralds the App Store for fueling "competition and growth in app development, leading to millions of jobs in the new app economy and facilitating more than $100 billion in payments to developers worldwide."

The Trump administration sided with Apple, as did the U.S. Chamber of Commerce and several computer and software industry groups. On the other side were 31 states and groups opposed to antitrust activities.

More:Finally over: Samsung and Apple settle longstanding patent dispute

More:Samsung wins Supreme Court fight with Apple