SAN FRANCISCO (Reuters) - California sued the U.S. Department of Justice on Monday over federal restrictions on some law enforcement grants to so-called sanctuary cities, continuing a legal counterattack by Democrats against President Donald Trump’s administration.

FILE PHOTO: U.S. Representative Xavier Becerra (D-CA) speaks on the final night of the Democratic National Convention in Philadelphia, Pennsylvania, U.S. July 28, 2016. REUTERS/Mike Segar

The city of San Francisco also filed its own lawsuit against the Justice Department late last week, saying the federal government has improperly sought to force local jurisdictions to enforce national immigration law by imposing funding conditions.

President Donald Trump issued a broad executive order in January targeting wide swaths of federal funding for cities that generally offer illegal immigrants safe harbor by declining to use municipal resources to enforce federal immigration laws.

However, a San Francisco judge drastically limited the scope of that policy in a previous lawsuit filed by the city.

The Justice Department then sought to impose conditions on a national grant for local law enforcement that mandates access to local jails for federal immigration officials, as well as 48 hours notice before releasing anyone wanted for immigration violations.

California’s lawsuit opposing those conditions, as well as San Francisco’s case, is similar to a legal challenge filed last week by the city of Chicago.

In a statement on Monday, California Attorney General Xavier Becerra said the state, not the federal government, is best suited to determine how best to allocate its law enforcement resources.

“When President Trump threatened to defund our local law enforcement’s ability to do its job and protect our people, he picked the wrong fight,” Becerra said.

A Justice Department spokesman could not immediately be reached for comment. The Trump administration contends that local authorities endanger public safety when they decline to hand over for deportation illegal immigrants arrested for crimes.

California receives about $28 million a year in federal law enforcement funding that would be subject to the new conditions, the state said in its lawsuit.

San Francisco City Attorney Dennis Herrera on Monday said San Francisco receives about $1.4 million in such funds. Immigration enforcement is the federal government’s job, he said.

“We’re not stopping them,” Herrera said. “But our police and deputies are focused on fighting crime, not breaking up hard-working families.”