SEATTLE (AP) — A federal appeals court gave President Donald Trump a rare legal win in his efforts to crack down on "sanctuary cities" Friday, upholding the Justice Department's decision to give preferential treatment in awarding community policing grants to cities that cooperate with immigration authorities.

The 2-1 opinion overturned a nationwide injunction issued by a federal judge in Los Angeles. The court said awarding extra points in the application process to cities that cooperate was consistent with the goals of the grant program created by Congress.

"The Department is pleased that the Court recognized the lawful authority of the Administration to provide favorable treatment when awarding discretionary law-enforcement grants to jurisdictions that assist in enforcing federal immigration laws," the Justice Department said in an emailed statement.

"This ruling reverses a lawless decision that enabled Sanctuary City policies, putting the safety and security of all Americans in harm's way," the White House said later Friday in an emailed statement. "We urge citizens across America to demand that Democrat leaders cease their support for Sanctuary policies that deprive Americans of life, limb, and liberty."

Federal courts have blocked some efforts by the administration to withhold money from sanctuary cities, including an executive order issued by the president in 2017 that would have barred them from receiving federal grants "except as deemed necessary for law enforcement purposes." Courts also barred the Justice Department from imposing new immigration enforcement-related conditions on Byrne Memorial Justice Assistance Grants, the biggest source of federal funding to state and local jurisdictions.

The 9th Circuit's ruling Friday concerned a different program, Community Oriented Policing Services, or COPS, grants, which are used to hire more police officers. Previously, the Justice Department has given extra points to cities that agree to hire veterans, or that operate early intervention systems to identify officers with personal issues, or that have suffered school shootings.

Story continues

In 2017, under then-Attorney General Jeff Sessions, the Justice Department for the first time decided extra points would go to cities that listed immigration enforcement as a priority or that certified they would cooperate with federal immigration authorities by allowing them access to detainees in city jails and giving 48 hours' notice before an undocumented immigrant was released from custody.

Los Angeles applied for a grant that year, but declined to list immigration enforcement as a priority — it listed building community trust instead — or to make the certification. It failed to win, and it sued.

The Justice Department had introduced conditions that impermissibly coerced the grant applicants to enforce federal immigration law, the city said. It also said the immigration-related conditions were contrary to the goals for which Congress had approved the grant money: to get more police on the beat, developing trust with the public.

The judges in the majority, Sandra Ikuta and Jay Bybee, both appointed by Republican President George W. Bush, rejected that.

"Cooperation relating to enforcement of federal immigration law is in pursuit of the general welfare, and meets the low bar of being germane to the federal interest in providing the funding to 'address crime and disorder problems, and otherwise ... enhance public safety,'" Ikuta wrote.

Several other jurisdictions did win funding without agreeing to the DOJ's immigration enforcement preferences, she noted.

Judge Kim Wardlaw, appointed by Democratic President Bill Clinton, dissented, calling the majority's opinion "Orwellian" in the way it tried to equate federal immigration enforcement with enhanced community policing.

"Nothing in the congressional record nor the Act itself remotely mentions immigration or immigration enforcement as a goal," she wrote. "In the quarter-century of the Act's existence, Congress has not once denoted civil immigration enforcement as a proper purpose for COPS grants."

The Los Angeles city attorney's office did not immediately respond to an email seeking comment.

Supporters of sanctuary cities say that encouraging local police to participate in federal immigration enforcement is counterproductive: People will be less likely to report crimes if they believe they'll be deported for doing so. But the 9th Circuit's opinion found that to be a question of policy, not law, said David Levine, a professor at University of California Hastings College of the Law.

"What the Justice Department was doing before, they were trying to force sanctuary cities to do things, and yank money from them retroactively if they didn't," Levine said. "They've gotten a little more sophisticated now. They're saying, 'You don't have to take this money, but if you want it, it comes with strings attached.' That's a well understood way the federal government gets states to do things. You don't use a stick, you use a carrot."