James Martin/CNET

A federal judge has thrown out a class action lawsuit brought against Apple by employees at its retail locations seeking back pay for time spent waiting in line each day for mandatory bag searches.

The decision filed Saturday by US District Court Judge William Alsup in San Francisco frees Apple from having to compensate more than 12,000 current and former employees at 52 stores throughout California for time spent waiting to have their bags searched when they went on breaks as well as at the end of their shifts over a six-year period.

In his ruling, Alsup wrote that employees were free not to bring a bag to work, thus avoiding the search process.

"Rather than prohibiting employees from bringing bags and personal Apple devices into the store altogether," he said.

"Apple took a milder approach to theft prevention and offered its employees the option to bring bags and personal Apple devices into a store subject to the condition that such items must be searched when they leave the store," Alsup said.

It's the second employment lawsuit Apple has resolved in the past two months. In September, Apple, along with Google, Intel and Adobe, agreed to pay $415 million to settle an antipoaching civil lawsuit that accused the companies of conspiring not to hire each other's employees. Filed by former employees of the companies involved, the lawsuit shed a light on the practice of some major tech industry players of allegedly working together to agree not to poach employees from each other.

The retail employees' lawsuit, brought in 2013 by two former workers from Apple stores in New York and Los Angeles, claimed employees at physical locations were required to stand in lines up to 30 minutes long every day for store managers to check their bags to ensure they weren't smuggling home stolen goods. Adding up these daily waits, the employees said they were deprived of dozens of hours of unpaid wages, which totaled about $1,500 per year.

The lawsuit was granted class action status in July.

Alsup's ruling comes nearly a year after the US Supreme Court ruled that Internet retailer Amazon did not have to pay its employees for the time spent in security check lines. The high court in December overturned a lower court's ruling that Amazon should compensate workers for their time because the screenings were a part of its employees' jobs and benefited the company.

Cupertino, California-based Apple declined to comment. Plaintiffs' attorney did not immediately respond to requests for comment.