After Ms. Miranda was sentenced to time served and was ready for release, the Clackamas County jail kept her for an additional 19 hours under a federal hold until immigration agents arrived to take her away.

In response to a lawsuit by Ms. Miranda questioning her prolonged detention, the county argued that the sheriff had been required to hold her by the federal detainer. Judge Stewart found that the detainer was not mandatory and “alone did not demonstrate probable cause” for Ms. Miranda to be held. The judge said the county was liable for damages, which have yet to be determined.

“The jail was making a decision not to release this person until immigration agents showed up,” said David Henretty, the lawyer at the Oregon Law Center in Portland who represented Ms. Miranda in the federal lawsuit. “Now the jails will not hold someone only on a detainer.”

Legal experts said the Oregon decision may be felt far beyond the state. “It could be a game-changer,” said Juliet Stumpf, a professor at Lewis and Clark Law School in Portland. “It opens potential liability for counties all over the country for following ICE’s requests.”

Immigration agents determined that Ms. Miranda, a longtime Oregon resident with two children who are American citizens, was in the country illegally. She is free on bail and fighting deportation, her immigration lawyer, Alejandro Villacorta, said.

The use of detainers by the immigration agency has expanded as a result of a program called Secure Communities, which the Obama administration extended to every law enforcement jurisdiction. Under the program, fingerprints of anyone booked by local or state police are checked against federal immigration databases. Based on those checks, ICE agents decide whether to ask the police to hold the immigrants.

An ICE spokeswoman, Barbara Gonzalez, said she was confident the agency would “continue to work cooperatively with law enforcement partners throughout Oregon.” She said the agency issued detainers on convicted criminals and other immigrants posing public safety threats to ensure they were not released into communities.