Updated

Arrestees who say they were denied bail because immigration agents wanted them held sued the Los Angeles County sheriff Friday claiming they were illegally detained for weeks or months.

The American Civil Liberties Union of Southern California filed the lawsuit in federal court in Los Angeles challenging Sheriff Lee Baca's ability to detain arrestees solely on the basis of a request from the federal immigration agency, when the inmates are eligible for bail or other forms of release.

Plaintiff Duncan Roy -- a British film director -- said he was held in jail for nearly three months because Immigration and Customs Enforcement had filed paperwork asking the Sheriff's Department to keep him in custody, even though he tried multiple times to post bail.

"The sheriff says, he's on an ICE hold, and the ICE people say, well, he's got to make bond," said Roy, who was eventually released after ICE withdrew its request, known as an immigration detainer, or hold. "They keep you in this limbo where each is blaming the other organization, but basically they're colluding with each other to keep you there."

Roy, who later pleaded no contest to a misdemeanor extortion charge, is one of several named plaintiffs among tens of thousands of inmates who should have been eligible for release but were detained because the department says it must honor the immigration holds, according to the ACLU.

ACLU staff attorney Jennie Pasquarella said the suit -- which seeks class-action status -- challenges the validity of immigration detainers, which have been increasingly used in jails across the country under the federal government's flagship immigration enforcement program.

"There has to be authority for them to actually deprive a person of liberty, and we're saying there isn't based on state and federal law," Pasquarella said.

Inmates should be allowed to leave custody if they post bail or qualify for release, then federal immigration authorities could seek to take them into custody if they so choose, immigrant advocates said.

Sheriff's spokeswoman Nicole Nishida said the department may hold people at the request of federal immigration authorities.

"If ICE tells us there's a hold, we're only doing what they wish," Nishida said, adding that the detainers are usually placed for 48 hours but could go longer depending on the case.

ICE said in a statement that the agency uses detainers to ensure that potentially dangerous criminals are not released from jails. On its website, the agency says that if immigration agents fail to take custody of an inmate after 48 hours, excluding weekends and holidays, local law enforcement agencies are required to release the inmate.

The lawsuit seeks an injunction ordering the sheriff not to detain anyone solely on the basis of an immigration hold, and damages for plaintiffs who were unlawfully held. In the suit, the ACLU states the Sheriff's Department recently agreed to put forth a policy clarifying that inmates should be able to post bail even if they have an immigration detainer.

The federal government's Secure Communities program lets immigration agents check arrestees' fingerprints against homeland security records to determine if someone might be in the country illegally.

The program has been touted by ICE as a crime-fighting tool but is reviled by many who say it discourages immigrants from reporting crime and erodes their trust in police. Amid growing opposition, a number of law enforcement agencies, including the Los Angeles Police Department, have announced plans to stop honoring requests by immigration agents to hold people accused only of minor crimes.

In the past four years, immigration agents have removed more than 220,000 people from the country under the program. Roughly 12 percent of them came from Los Angeles County, according to federal government statistics.