San Francisco filed a lawsuit on Tuesday challenging President Donald Trump's executive order directing the US government to withhold money from cities that have adopted sanctuary policies toward undocumented immigrants.
The lawsuit, filed by San Francisco City Attorney Dennis Herrera, marks the first court challenge over the sanctuary order filed by one of the targeted cities.
Mr Trump signed the directive on sanctuary cities on 25 January, along with an executive order to build a wall along the US-Mexican border, as he charged ahead with sweeping and divisive plans to transform how the US deals with immigration and national security.
Local officials in cities such as New York, Los Angeles, Chicago, Philadelphia, Boston, Denver, Washington and Seattle, as well as San Francisco, offer some forms of protection to illegal immigrants.
Billions of dollars in federal aid to those cities could be at risk.
Tuesday's lawsuit alleges that the executive order violates the 10th Amendment of the US Constitution, which states that powers not granted to the federal government should fall to the states.
"In blatant disregard of the law, President of the United States seeks to coerce local authorities into abandoning what are known as 'Sanctuary City' laws and policies," said the lawsuit, filed in San Francisco federal court.
Mr Herrera told reporters at City Hall on Tuesday morning the city's sanctuary policy was borne out of a desire to allow and encourage undocumented immigrants to report crimes to police without fear of being deported.
He said such policies make residents safer and cited research suggesting that counties and cities with sanctuary policies, of which he estimated there were 400 across the country, had fewer crimes per 10,000 residents than other jurisdictions.
"President Trump's executive order tries to turn city and state employees into federal immigration officers. That is unconstitutional," Mr Herrera said.
The suit seeks to halt Mr Trump's order and also calls on a judge to declare that San Francisco is in compliance with federal law.
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies