The lawsuit seeks to prevent Apple from locking iPhones and choosing what applications users can install. It also seeks damages to cover legal fees.
The lawsuit claims that users were locked into a two-year agreement with AT&T but the lockup period was actually much longer, as AT&T has remained the exclusive U.S. carrier.
Judge James Ware of the U.S. District Court for the Northern District of California issued the ruling.
Apple has sold more than 50 million iPhones in the last three years. The company does not specify how many have gone to U.S. customers.
AP contributed to this report.