The Justice Department is battling in the courts to preserve President Trump’s anti-sanctuary city agenda, but it’s already notched some successes just by raising the issue.

Several major jurisdictions have said they’ll work with federal deportation officers, forgoing previous uncooperative policies, after Attorney General Jeff Sessions threatened to withhold federal grant money.

“Just telling people they are getting serious about it has already helped,” said Jessica Vaughan, director of policy studies at the Center for Immigration Studies. “In some ways it gives any politicians who were lukewarm on the sanctuary policies some leverage with the city council or whoever it was who imposed the policies.”

Miami-Dade County in Florida changed its policies to be more cooperative in the early days of the Trump administration, and this month New Orleans officials met with Mr. Sessions to smooth out disagreements over the city’s cooperation.

But the successes have been matched by renewed resistance from other jurisdictions ranging from San Francisco to Chicago and Philadelphia, each of which is battling in court to try to stop the administration’s funding threats.

By Tuesday the Justice Department must file briefs in the 7th U.S. Circuit Court of Appeals in Chicago, seeking to break a nationwide injunction a lower court has imposed on the administration’s plans to tie money from the Byrne Memorial Justice Assistance Grant Program to cooperation on immigration matters.

The department has held off on distributing $257 million in 2017 grants to police departments across the country, concerned that if the money is distributed before the legal battles are settled, that it won’t be able to ensure cities follow the rules.

The lower-court judge in the Chicago case ruled Mr. Sessions exceeded his authority by adding two new levels of cooperation to the Byrne grants: requiring cities to let federal agents into their prisons and jails, and to give at least 48 hours notice before releasing illegal immigrants so deportation officers can be on hand to pick them up.

The judge upheld a third condition Mr. Sessions imposed, which prohibits state and local governments from restricting communications with federal immigration authorities “regarding the citizenship or immigration status” of individuals.

Federal judges in Pennsylvania and California have also issued rulings against the grant plan.

One judge ruled that Philadelphia had adequately complied with the conditions the Justice Department set to impose on the grants, and that the Justice Department could not withhold $1.6 million in funds destined for the city this year.

On Monday U.S. District Judge William Orrick blocked the Trump administration’s executive order, which directed agencies to find ways to deny federal funding for cities that refused to provide information on illegal immigrants to U.S. Immigration and Customs Enforcement.

The ruling, issued following lawsuits brought by San Francisco and Santa Clara counties in California, rejected the administration’s argument that the executive order applies only to a relatively small pot of money and said Mr. Trump cannot set new conditions on spending approved by Congress.

Justice Department spokesman Devin O’Malley said the San Francisco court “exceeded its authority,” and the department “will vindicate the president’s lawful authority to direct the executive branch.”

Lawmakers could pass clarifications that make it easier for DOJ to enforce its policy, or it could seek to clarify exactly what local law enforcement has to do in order to be considered compliant with ICE, she said.

The Justice Department also put 29 states, counties and cities on notice this month that they may be asked to pay back more than $17 million in federal grant money unless they’re able to prove their policies don’t violate federal law.