(Bloomberg) — Apple Inc. violated a court order requiring it to open up the App Store to third-party payment options and must stop charging commissions on purchases outside its software marketplace, a federal judge said in a ruling that referred the company to prosecutors for a possible criminal probe.

Most Read from Bloomberg

US District Judge Yvonne Gonzalez Rogers sided Wednesday with Fortnite developer Epic Games Inc. over its allegation that the iPhone maker failed to comply with an order she issued in 2021 after finding the company engaged in anticompetitive conduct in violation of California law.

Gonzalez Rogers also referred the case to federal prosecutors to investigate whether Apple committed criminal contempt of court for flouting her 2021 ruling. The US attorney’s office in San Francisco declined to comment.

The changes the company must now make could put a sizable dent in the double-digit billions of dollars in revenue the App Store generates each year. Apple is potentially facing another multibillion-dollar hit from losing payments Google makes to be the default search engine for its Safari browser, which is the subject of an ongoing Justice Department antitrust case against the Alphabet Inc. unit.

Apple’s share price declined about 1.6% in after-hours trading Wednesday.

After several weeks of hearings last year and this, Gonzalez Rogers concluded Wednesday that Apple “willfully” violated her injunction.

“It did so with the express intent to create new anticompetitive barriers which would, by design and in effect, maintain a valued revenue stream; a revenue stream previously found to be anticompetitive,” she wrote in her 80-page ruling. “That it thought this court would tolerate such insubordination was a gross miscalculation.”

Apple said in a statement that it strongly disagreed with the decision.

“We will comply with the court’s order and we will appeal,” a company representative said.

Epic Games Chief Executive Officer Tim Sweeney called the ruling a “huge victory for developers,” saying in a phone call with journalists it “forces Apple to compete with other payment services rather than blocking them.”

Following a trial in 2021, Gonzalez Rogers largely sided with Apple, saying that its App Store policies didn’t violate federal antitrust law. However, she required the company to let developers bypass its in-app payment tool to avoid a commission of up to 30%. The ruling was ultimately upheld by the US Supreme Court last year when it declined to hear appeals in the case.