Follow CBSPHILLY Facebook  | Twitter

PHILADELPHIA (CBS/AP) — A federal judge ruled Wednesday that the Trump administration cannot cut off grants to Philadelphia over the way the city deals with immigrants in the country illegally.

A sanctuary city is one that welcomes immigrants including those undocumented.

U.S. District Judge Michael Baylson said in his ruling that the conditions the federal government placed on the city in order to receive the funding are unconstitutional, “arbitrary and capricious.” He also wrote that Philadelphia’s policies are reasonable and appropriate.

Philadelphia has said it will turn over immigrants to Immigration and Customs Enforcement only if the agency has a warrant signed by a judge.

Man Sentenced To 20 Years In Prison For Stealing Over $160, Chicken Wrap From Wawa At Gunpoint

The federal requirements included allowing Immigration and Customs Enforcement officers access to prisons to interview people of interest, providing advanced notice of release of those people and following rules prohibiting restrictions on disclosure of any person’s immigration status.

“The public statements of President (Donald) Trump and Attorney General (Jeff) Sessions, asserting that immigrants commit more crimes than native-born citizens, are inaccurate as applied to Philadelphia, and do not justify the imposition of these three conditions,” Baylson wrote.

The federal government has deemed Philadelphia a sanctuary city and Attorney General Jeff Sessions has withheld $1.5 million in federal funds until the city complies with federal immigration rules, so the city sued the federal government for that cash.

Federal attorneys had said the city’s policies put federal immigration agents in danger and create situations where criminals in the country illegally are released and allowed to reoffend.

Philadelphia Mayor Jim Kenney applauded the ruling, saying a “White House run by a bully” can’t bully the city into changing its policies. He also added that Attorney General Jeff Sessions can’t use federal dollars for shakedowns.

“This country was not created to be divided, it was created to be united,” said Kenney.

The city had said that the requirements on federal grant spending were unconstitutional and that following them would promote a perception in the community that it was serving as an arm of federal immigration enforcement. City attorneys had argued that would create a barrier for immigrants to seek out city services ranging from health care to calling the police when they’re victimized.

5 New Jersey Beaches Under Advisories After Unsafe Levels Of Fecal Bacteria Found

Baylson wrote that Philadelphia is entitled to prompt payment of the grant funds, but he has given the city and Justice Department time to suggest language for a final decree making that an order.

“Today’s opinion from the district court in Philadelphia is a victory for criminal aliens in Philadelphia, who can continue to commit crimes in the City knowing that its leadership will protect them from federal immigration officers whose job it is to hold them accountable and remove them from the country,” said Justice Department spokesman Devin O’Malley. “The Justice Department continues to maintain that we exercised our authority, given by Congress, to attach conditions—designed to keep Americans safe—to public safety grants, and we will continue to fight to carry out the Department’s commitment to the rule of law, protecting public safety, and keeping criminal aliens off the streets.”

The U.S. Justice Department declined to comment to CBS3 on if they will appeal the ruling.

Several other “sanctuary cities” have opted to limit cooperation with government enforcement of immigration law. The Justice Department has threatened to cut off millions of dollars in federal grants to cities if they don’t meet certain criteria for cooperating with immigration officials. Philadelphia’s attorneys had argued the move is unconstitutional and that it harms residents by withholding money earmarked to help buy kits to counteract opioid overdoses.

Sessions has said that cities that don’t help enforce immigration law are endangering public safety, especially when it comes to sharing information about immigrants who have been accused of crimes.

A federal appeals court in April sided with Chicago in a similar dispute.

(© Copyright 2018 CBS Broadcasting Inc. All Rights Reserved. The Associated Press contributed to this report.)