A federal judge on Friday ordered Apple to alter its contracts with e-book publishers to ensure price competition in a closely watched decision that could ripple across Internet commerce for videos, music and other media.

U.S. District Judge Denise Cote issued a permanent injunction against Apple, forcing the firm to alter contracts that contain “most favored nation” clauses, or preferred treatment that gives the iPad maker the ability to control prices offered to competitors.

The judge barred Apple for five years from entering into any agreements with such favorable terms that would prevent retail e-book prices from dropping. She also ordered an outside auditor to monitor the company’s compliance with her order for two years.

In July, Cote, of the U.S. District Court of the Southern District of New York, ruled that Apple conspired with publishers Hachette Book Group, HarperCollins, Macmillan, Penguin and Simon & Schuster to raise prices of e-books.

The Justice Department, which filed suit against Apple and the publishers in April 2012, said consumers were hurt by the alleged price-fixing scheme. All publishers settled with Justice before the case went to trial.

The government’s suit stirred controversy, because Apple was seen as a newcomer to an industry dominated by Amazon. Some observers noted that Amazon had nearly 90 percent of the digital-book market upon the launch of Apple’s iBookstore in 2010, and publishers had been frustrated by Amazon’s low pricing of book titles on its Kindle device.

But the Justice Department said agreements between Apple and the publishers to try to raise e-book prices a few dollars above what was being offered on Amazon’s Kindle was illegal and hurt consumers.

“Consumers will continue to benefit from lower e-books prices as a result of the department’s enforcement action to restore competition in this important industry,” said Bill Baer, head of Justice’s antitrust division. “By appointing an external monitor to ensure future compliance with the antitrust laws, the court has helped protect consumers from further misconduct by Apple.”

Apple vowed to appeal the injunction. Some analysts say the case, a precedent-setting ruling in the nascent digital media space, could reach the Supreme Court.

Apple has much to lose. Its iTunes business is built on the distribution of video, music and other media content. Any legal restrictions could ripple across iTunes and other tech firms, analysts say.

“Apple did not conspire to fix e-book pricing. The iBookstore gave customers more choice and injected much needed innovation and competition into the market,” Apple spokesman Tom Neumayr said in a statement.

Cote’s order was limited to Apple’s activities in the e-book market, but antitrust experts said the order will give other tech companies pause as they determine whether their contracts abide by antitrust laws.

The market for digital commerce has been largely unregulated. But the case signaled interest by antitrust authorities in policing the burgeoning industry, experts say.

The government “doesn’t bring that many cases, so this does set a marker,” said Joseph Bauer, a law professor at the University of Notre Dame. “It says that if you engage in unlawful behavior, the DOJ may go after you. Apple may not be a big player in the e-books market, but they are big in a lot of other areas.”

Follow The Post’s new tech blog, The Switch, where technology and policy connect.