Chicago escalated its ongoing feud with the Trump administration on Monday with a lawsuit that accuses the Justice Department of forcing the city to police undocumented immigrants in a way that would violate peoples' rights, damage public trust and make the city less safe.

But left unsaid in that argument is the city's long history of, allegedly, doing just that.

Chicago has suffered through many years of police scandals marked by beatings, shootings and forced confessions. In January, just before President Donald Trump took office, the Justice Department released a report outlining a litany of abuses by Chicago police against black and Latino residents, including the unnecessary use of force, which federal investigators said was driven by policies that devalued relationships with "marginalized" communities.

The report also documented officers expressing on social media "discriminatory views" against people based on race, gender and national origin, and complaints that the department failed to aggressively investigate hate crimes against immigrants.

Chicago Mayor Rahm Emanuel, right, stands with Chicago Corporation Counsel Ed Siske, center, and Chicago Police Department (CPD) Superintendent Eddie Johnson as he announces that the City of Chicago will file a federal lawsuit to prevent the Justice Department from making a federal crime prevention grant conditional on immigration enforcement policies on Aug. 6, 2017 in Chicago. Scott Olson / Getty Images

"A striking feature of our conversations with members from Chicago's challenged communities was the consistency with which they expressed concern about the lack of respect in their interactions with police, whether those interactions come when they are targets of police activity or when they or their family members are the victims of crime," the investigators wrote in January.

Related: Chicago Police Department Routinely Violated People’s Rights, Feds Say

The city, which has more murders this year than New York and Los Angeles combined, accepted those findings, and began negotiating with the Justice Department on how to implement reforms. But Mayor Rahm Emanuel has since resisted oversight by a court-appointed monitor.

Trump, meanwhile, has frequently derided Chicago, using it as a byword for urban or "inner-city" crime, threatening to "send in the feds," and questioning Emanuel's crime-fighting strategies.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Emanuel, in turn, has taken a leading role in the resistance to Trump's crackdown on so-called "sanctuary cities" ─ municipalities that have refused to cooperate in the administration's attempt to round up and report more undocumented immigrants. U.S. Attorney General Jeff Sessions has threatened to withhold crime-fighting grants from agencies that do not comply with a section of federal law that allows information sharing with immigration officials.

Related: Spurred by Trump, States Battle Sanctuary Cities

Among the targets is the Edward Byrne Memorial Justice Assistance Grant. Chicago has received money from the program each year since its creation in 2005, using it to buy police cars, equip officers and fund nonprofit groups in high-crime neighborhoods. But in late July Sessions made the grants contingent on applicants' allowing federal agents into their jails and giving give them 48 hours' notice before releasing undocumented immigrants.

That prompted Chicago's lawsuit, filed Monday. In it, the city said the requirements would force the city to violate defendants' Constitutional rights and "sow fear in local immigrant communities," making them less likely to report crimes or come forward as witnesses.

The Emanuel administration argued that the city, which has had its own hands-off immigration law on the books since 1985, would ultimately become less safe.

"If Chicago submits to the Department’s demands, it will forfeit decades’ worth of trust and goodwill that its police force has built in the communities it serves," the city alleged in the lawsuit. "And as those decades of experience show, that kind of trust, once lost, is lost forever."

Emanuel, in a statement, said he refused to be "blackmailed" into choosing "between our values and our Police Department’s philosophy of community policing.”

Related: AG Sessions Threatens ‘Sanctuary Cities,’ Mayors Fight Back

Civil rights advocates, who generally backed the aim of the lawsuit, said they found Chicago's legal argument curious, given the allegations of routine police abuses.

"I support what they're doing there with taking a stand against the Department of Justice. But the irony is hard not to notice, particularly when the mayor now is fighting tooth and nail to avoid oversight of the police department," said Craig Futterman, a University of Chicago law professor who is representing a coalition of local organizations trying to force the city into court oversight.

Analia Rodriguez, executive director of the Latino Union of Chicago, an immigrants' rights group, said the city's lawsuit ultimately aims to obtain more money to fund an agency that has "overpoliced" minority communities, often in discriminatory ways.

She cited gang databases as one source of biased treatment, with many immigrants placed on lists that she said made them vulnerable to deportation via loopholes in Chicago's sanctuary city policy.

"We're saying we are a sanctuary city and need this money, and in actuality what we're doing is over-policing and criminalizing our communities," Rodriguez said.

City officials countered that they were at least trying to head in the right direction and didn't want Sessions holding them back.

“Chicago is moving forward on the road to reforming its police department and improving its community policing efforts, however, we will also not sit idly and allow the erosion of our values and principles to comply with the unlawful and unconstitutional demands from the Trump Justice Department," Chicago Department of Law spokesman Bill MCCaffrey said in a statement.

Sessions responded to the lawsuit by accusing Chicago of obstructing the U.S. immigration system, "protecting criminal aliens who prey on their own residents" and failing to address the murder rate.

“The mayor complains that the federal government’s focus on enforcing the law would require a ‘reordering of law enforcement practice in Chicago,’" Sessions said in a statement. "But that’s just what Chicago needs: a recommitment to the rule of law and to policies that rollback the culture of lawlessness that has beset the city."