When Los Angeles police officials requested $3.125 million in federal funds in 2017 to hire 25 officers, they said their focus would be on "building trust and respect" through community policing.
In keeping with longstanding city policy, they did not cite "illegal immigration" as a focus for the new officers, or indicate that the proposed hires would work with immigration agents to help deport immigrants being held in local jails.
The grant money went elsewhere, and Los Angeles sued, saying it was being punished for its stance.
A federal appeals court rejected that lawsuit Friday, ruling 2-1 that the Trump administration may give preference in awarding grants to police departments that help federal authorities nab immigrants.
The ruling by the 9th U.S. Circuit Court of Appeals was a setback for Los Angeles, which won a nationwide injunction against the grant application process last year.
Los Angeles City Attorney Mike Feuer said the city would explore all options, including an appeal to a larger panel of the 9th Circuit.
"If this decision were to stand, this or another administration could add other conditions, favoring jurisdictions that criminalize abortions or allow teachers to have guns in classrooms," Feuer said.
Friday's legal victory for Trump followed a string of failures in his efforts to punish so-called sanctuary cities and counties. All courts that have heard those cases decided the administration could not deny communities federal funds simply because they refused to assist immigration agents.
At issue in the newest case was a competitive grant program called the Community Oriented Policing Services, or COPS. Congress created the program in 1994 for community-based policing.
In 2017, the U.S. Department of Justice adopted a new scoring system for deciding which agency would receive the grants. Extra points were given to departments that wanted to hire officers to help federal authorities deport immigrants.