The lawsuit, the first of its kind, challenges the Trump administration's requirement that cities detain suspects for questioning by federal immigration authorities or see their grant funding for municipal police departments withheld.
Chicago Mayor Rahm Emanuel on Monday called the policy counterproductive.
The nation's highest law enforcement official, Attorney General Jeff Sessions -- who is named in the lawsuit -- responded by sharply rebuking the city and its mayor.
"This administration will not simply give away grant dollars to city governments that proudly violate the rule of law and protect criminal aliens at the expense of public safety," Sessions said in a statement.
Emanuel told CNN the federal government is presenting a "false choice."
"By forcing us, or the police department, to choose between the values of the city and the philosophy of the police department... it undermines our actual safety agenda," Emanuel said.
"We will always be a welcoming city," he continued, adding that local police departments rely on the cooperation of the immigrant community -- both documented and undocumented.
Supporters of "sanctuary city" policies say such cooperation could erode if local police are required to fully cooperate with immigration enforcement.
The federal grant at the center of the lawsuit provided $2.3 million to Chicago last year to purchase police equipment such as cars, computers, radios and Tasers, Emanuel said.
The federal government's new rules would tie the grant to requirements that, among other things, cities give federal immigration authorities unlimited access to local police stations to interrogate arrestees, Chicago officials said.
The city is asking a federal court to declare such requirements unlawful.
'Sanctuary cities' targeted by Trump
Trump has targeted sanctuary cities as part of his promised crackdown on illegal immigration, and the Department of Justice implemented the new funding requirements last month.
Sessions, who heads the Department of Justice, pointed to Chicago's high murder rate as evidence that the city needs to reform its law enforcement practices. "To a degree perhaps unsurpassed by any other jurisdiction, the political leadership of Chicago has chosen deliberately and intentionally to adopt a policy that obstructs this country's lawful immigration system," Sessions said.
Sessions contends the new funding policy would improve safety for immigration officers who have to track down suspects who were detained and then released by local police.
Having to re-arrest immigrants puts officers under additional danger, he has said.