City lawmakers voted Wednesday to limit compliance with federal immigration officials who want arrestees in city custody held for deportation proceedings based solely on suspicions that they are in the country illegally.

The NYPD and the Department of Correction may not honor detainer requests by the Immigration and Customs Enforcement Agency, or ICE, without a judicial warrant, according to a pair of bills that both passed by 41-6 votes in the City Council. If ICE presents a warrant, the city may comply only if the arrestee has been convicted of a violent or serious crime within the last five years or is a possible match on the federal terror watch list.

The city may cooperate without a warrant if the person has been convicted and previously deported or is a possible watch-list match.

The measure is meant to protect low-level offenders from deportation and to keep families together, said City Council Speaker Melissa Mark-Viverito (D-Manhattan). "We're a city that respects the constitutional rights of all of our residents," she said.

Councilman Paul Vallone (D-Queens) was among those who voted against the bills. He said city government should not interfere with public safety efforts aimed at thwarting serious offenders.

The bills, which a spokeswoman for Mayor Bill de Blasio said he supports and plans to sign into law, also would remove ICE from the Rikers Island jail complex, where it now keeps an office and operates a local detention program.

ICE spokesman Luis Martinez said the agency "requests detainers on individuals arrested on criminal charges to ensure that dangerous criminals are not released from prisons or jails and into our communities" and will continue to cooperate with the city to identify and remove "convicted criminals and other public safety threats."