Philadelphia is suing Attorney General Jeff Sessions in federal court over his attempt to withhold grant money from "sanctuary cities."

Chicago, Los Angeles, San Francisco, and California have also filed similar suits over new restrictions on a federal grant that funds police training and overtime. Sessions announced the changes in July.

Last year, the city received $1.67 million. Then, under President Barack Obama, city officials were told that to keep receiving the grant, they would have to certify compliance with a federal law banning any local laws that prohibit communication with Immigration and Customs Enforcement about residents' immigration status.

Sessions has added two requirements to that grant. When ICE requests it, cities must give immigration agents two days' notice before releasing undocumented inmates from custody. And they must allow ICE access to any detention facility to question immigrants held there "about their right to be or remain in the United States."

The city is asking for a federal judge to grant an injunction against the requirements for the grant because they were not authorized by Congress and violate the 10th Amendment by commandeering local governments to do the work of federal law enforcement, among other arguments.

"All of this is political," Mayor Kenney said Wednesday. "It's Sessions trying to cozy up to Trump because he was in the doghouse." (Sessions announced the restrictions during a week of near-constant criticism from President Trump over his decision to recuse himself from the investigation into possible Russian meddling in the presidential election.)

Trump, Kenney said, has "no interest in the people who live here, and he's trying to score political points with the 32 percent of his base he still has."

Sessions and Trump have argued that sanctuary city policies release dangerous criminals into communities. Devin O'Malley, a representative for the Department of Justice, said in an email that Philadelphia had "joined other jurisdictions in doing a disservice to their citizens by protecting criminal aliens rather than law-abiding citizens" and noted Philadelphia's murder rate, which is up 7 percent this year.

But city officials have countered that undocumented immigrants receive no special treatment under the policies, which they say have cut down on crime and built trust between immigrant communities and police: "We've had the lowest crime rate in 40 years," Kenney said. The lawsuit says violent crime declined 20 percent since 2009, when they city directed all of its employees not to ask about anyone's immigration status.

Kenney said that immigrants have been key to Philadelphia's success in recent years — reversing 50 years of population loss and swelling the workforce.

Juntos, the Philadelphia-based immigrant-rights organization, said Wednesday that it supports the suit.

"What we are witnessing is without a doubt both Trump and Sessions trying to make law enforcement in this country into what can only be described as their personal Gestapo, targeting and downright decimating communities of color," said Erika Almiron, Juntos' executive director. "Philadelphia needs to once again be on the vanguard and take the steps necessary to defend our people."

Councilwoman Helen Gym also expressed support for the move, saying the Trump administration is "making up rules as they go, and it's up to our cities to say, 'Not on our watch.' "

City Solicitor Sozi Pedro Tulante, a former assistant U.S. attorney, said the city will argue in court that only Congress has the power to impose restrictions on grants — and that Sessions' restrictions are unconstitutional.

"The grants have nothing to do with enforcing immigration laws," Tulante said. "There's no federal statute that authorizes Sessions to apply these conditions. The Trump administration is entitled to disagree with our policies, but they cannot make up rules beyond the directives of Congress."

Tulante said the city has "good reasons" for its sanctuary city policies, which forbid police from asking the immigration status of people they encounter and require ICE to get a warrant before the city will release an inmate into its custody. The city also does not give ICE notice before releasing an inmate.

Most of the people in Philadelphia's prison system are awaiting trial or sentencing, Tulante said, and the city itself generally doesn't get notice if those inmates post bail or are ordered released by a judge. Those who are serving out their sentences in city jails, Tulante said, are generally not targeted by ICE. And agents are able to interview prisoners in city jails — but the city asks inmates if they want to speak with ICE beforehand, and notifies them of their rights.

The new restrictions, he said, are an "attempt to make our prison officials part of federal immigration law and enforcement."

The city will still apply for the policing grant despite the restrictions, officials said.

Still, the city wrote in its lawsuit, "the administration has made confusing and threatening public statements" that have left officials uncertain if their application will be accepted.