A federal judge has ruled Trump cannot block funding to the cities.
The Justice Department sent out letters to 29 cities, counties, and states on Wednesday warning that they are breaking the law.
Gov. Jerry Brown, a Democrat, has expressed support for the California Values Act and is expected to sign the restrictions into law.
The city says conditions of a Justice Department grant program are unconstitutional.
The lawsuit is in response to Jeff Sessions' threat to cut funding to sanctuary cities.
The Trump administration's support for anti-sanctuary city laws also face more legal hurdles.
An exclusive analysis shows an increase in legislative activity related to sanctuary jurisdictions, which comes as Trump has pushed back against such designations.
Authorities have insisted the flyers, which told people to report "illegal aliens," are not real.
Matt Rindali claimed he had been threatened and assaulted after calling ICE on a group of people protesting the state's sanctuary cities legislation.
A network of activists, clergy and lawyers are advising residents, communities and houses of worship on how to provide sanctuary to undocumented residents.
The blurred lines between criminal investigations and immigration enforcement is spreading panic and outraging public officials in California cities.
On Monday, the attorney general threatened to cut Department of Justice grants to the cities.