Apple won the biggest battle in its endless patent war with Samsung, but now it's Samsung's turn to be victor. A trade agency ruled Tuesday that several older Apple products violate a Samsung patent and can't be sold within the United States.

The International Trade Commission's long-awaited ruling bans Apple from importing or selling the AT&T (T)-compatible models of the iPhone 4, 3GS and 3, as well as the AT&T 3G-connected versions of the iPad and iPad 2.

Those products -- which are, like most tech products, assembled overseas and must be imported -- infringe on a Samsung patent for encoding mobile communications, the ITC ruled.

The ban does not affect the newest generation of Apple's products, the iPhone 5 and the fourth-generation iPad, which use different technology than the earlier devices.

The commission did not find that Apple violated any of the three other patents Samsung named in its case. But the rest of the ruling is a big blow to Apple (AAPL) -- and it comes as a surprise, given that a previous preliminary ruling from an ITC judge exonerated Apple completely.

This time, the "determination is final, and the investigation is terminated," the ITC wrote in its decision. Apple can file an appeal with the Federal Circuit, however, and spokeswoman Kristin Huguet said the company plans to do just that.

Apple can also hope for a veto from President Obama. The ITC is required by law to send its "exclusion orders" to the president for a 60-day review. Unless President Obama actively strikes down the order, it becomes final.

Because Apple plans to appeal, Tuesday's decision "has no impact on the availability of Apple products in the United States," Huguet said.

She slammed Samsung for "using a strategy which has been rejected by courts and regulators around the world" in other cases. She also accused Samsung of trying "to block the sale of Apple products by using patents they agreed to license to anyone for a reasonable fee."

A Samsung spokeswoman fired back that the ITC's ruling "has confirmed Apple's history of free-riding on Samsung's technological innovations." AT&T declined to comment.

Last year, a California jury found that several Samsung products infringed on Apple patents for software features like double-tap zooming and scrolling. The jury initially recommended that Apple be awarded more than $1 billion in damages. A final ruling in that separate case isn't expected until later this year.