WASHINGTON — The Department of Justice found New York City isn’t complying with federal immigration laws and ordered the Big Apple to prove it’s not a sanctuary city by Oct. 27 or risk losing millions in federal grant dollars.

A Justice Department review of New York City’s laws and policies found at least four provisions appear to violate federal immigration laws, according to an Oct. 11 letter obtained by The Post.

The Justice Department informed the city it has two weeks to certify such laws don’t prohibit the NYPD from sharing immigration status with federal officers, including tipping them off when a criminal undocumented immigrant suspect is released from their custody.

“Jurisdictions that adopt so-called ‘sanctuary policies’ also adopt the view that the protection of criminal aliens is more important than the protection of law-abiding citizens and of the rule of law,” Attorney General Jeff Sessions said in a statement to The Post.

Mayor Bill de Blasio is prepared for a legal battle against the Trump Adminstration.

“We are fully in compliance with the law,” de Blasio said Thursday. “The NYPD deserves the anti-terrorism funding they’ve gotten from the federal government. And if president Trump stops our funding for the NYPD, we will see the president in court. It’s as simple as that.”

The decision follows an April notification to New York City and eight other local governments asking them to prove they aren’t giving official sanctuary to illegal immigrants.

This week, the Justice Department issued a preliminary finding of noncompliance with immigration laws to five of those jurisdictions: New York City; Cook County, Illinois; Chicago; New Orleans, and Philadelphia.

“I urge all jurisdictions found to be out of compliance in this preliminary review to reconsider their policies that undermine the safety of their residents,” Sessions said.

The Justice Department review brought better news for others. It cleared Milwaukee, Wisconsin, and the state of Connecticut of any sanctuary city wrongdoing, joining Clark County, Nevada, and Miami-Dade County, Florida, which had been previously exonerated.

Sanctuary cities can be denied federal dollars under President Trump’s Jan. 25 executive order designed to crack down on localities that protect undocumented immigrants from federal immigration authorities.

Justice Department grants are contingent on cities agreeing to share information with the feds on individuals’ immigration status and giving 48-hour notice before releasing from jail an undocumented immigrant accused of committing a crime.

Several jurisdictions have filed suit against the federal government, arguing such orders violate the 10th Amendment by compelling states to enforce federal immigration laws.

“The Supreme Court under Justice Roberts… in 2012 said that the federal government cannot for political reasons withhold funding of this nature,” de Blasio said. “That was reiterated in another court action recently. We are in full compliance and if they want to have a court battle, we are ready for that court battle.”

The Justice Department has threatened to cut off federal dollars to New York City if it doesn’t change its policies.

One program in jeopardy is a $4.3 million grant through the Edward Byrne Memorial Justice Assistance Grant program, named for the NYPD officer who was ambushed in 1988 while protecting a witness who had agreed to testify against local drug dealers in Queens.

There are other Justice Department grant programs that bring in millions more.

De Blasio has defended the sanctuary city policy, saying he won’t turn the NYPD into a deportation force that breaks apart families.

The city laws permit the NYPD to honor ICE detainer requests — but only those convicted of certain crimes. De Blasio’s administration has compiled a list of 170 felonies, but critics say it’s not enough.