LOS ANGELES — A federal judge issued a nationwide injunction Thursday barring the U.S. Justice Department from giving priority status for multimillion-dollar community policing grants to departments that agree to cooperate with immigration officials.

The ruling came after Los Angeles, a sanctuary city, filed a request for the injunction.

“This is yet another dagger in the heart of the administration’s efforts to use federal funds as a weapon to make local jurisdictions complicit in its civil immigration enforcement policies,” Los Angeles City Attorney Mike Feuer said.

The Justice Department did not comment on the ruling.

The federal COPS Hiring Program awards more than $98 million to police departments across the country to hire more officers for community policing.

In September, Attorney General Jeff Sessions said departments could receive additional points in the application process by agreeing to fully cooperate with immigration authorities. Sessions has defended the policies as necessary to help fight illegal immigration. He has said that cities that don’t help enforce immigration law are endangering public safety.

Los Angeles was not awarded one of the grants in 2017. It alleged in seeking the injunction that the Justice Department has overstepped its authority and violated the constitution by linking the money to cooperating with immigration authorizes.

In his ruling, U.S. District Judge Manuel Real said the conditions would “upset the constitutional balance” by forcing police to participate in immigration enforcement.

The Los Angeles Police Department has routinely applied for the grant. The department was awarded $3.1 million in 2016 and $16.8 million between 2009 and 2012, police Chief Charlie Beck said.

The Justice Department wanted Los Angeles police to provide access to city jails, share technical information about investigations and allow access to information about arrestees, Beck said.

Many cities in the country have implemented sanctuary laws as a way to focus law enforcement officers on local crime rather than detaining people suspected of being in the country illegally.