New York’s immigrant communities are reeling from the over 40 arrests of undocumented immigrants that occurred across the city this month as part of a nationwide deportation drive. But the legal fate of these immigrants, once swept into ICE custody, is unknown; many may be detained for weeks or months as their cases wend through federal deportation proceedings. And the White House has widened the net to potentially ensnare more people with minor criminal histories, under the pretext of enforcing “public security.”

In the wake of these raids, New York City authorities have proudly declared themselves a “sanctuary city” in defiance of the Trump administration. New York Mayor Bill de Blasio has said that the City will maintain its sanctuary procedures under Trump. But the City’s protections are simply a general policy of municipal agencies’ and officials’ not proactively cooperating with ICE’s enforcement actions; ICE can still conduct operations using facilities and agents directly under Homeland Security’s control.

This supposed urban sanctuary therefore regularly disappears its migrants into a legal no-man’s land just outside city limits. A new report shows that, in detention, residents facing deportation are stripped of their rights and denied basic health care in the name of “security.”

The report by New York Lawyers for the Public Interest (NYLPI) recounts nearly 50 cases of detainees’ facing deportation from 2014 to 2015 in ICE-contracted, publicly run jails in Orange County in New York, and Hudson and Bergen counties in New Jersey. These facilities regularly absorb immigrants from New York City and surrounding areas apprehended by federal authorities. The rights abuses described in the report reflect patterns of health-care mismanagement across the ICE detention system nationally. Immigrant detainees in deportation proceedings, researchers say, suffered “devastating health consequences such as emergency surgery, delayed cancer diagnoses and worsening conditions of treatable diseases and pain.”

One interviewee who suffered a chronic heart condition, identified in the report as Mr. Ahmed, said ICE repeatedly ignored his requests for assistance with a problem with his pacemaker, until he had to resort to emergency surgery to replace the pacemaker battery. “When I was detained I thought at some point I would be dead. They think we are animals and we just have to accept whatever they say,” he recalled.

Though the detainees profiled in the report often came into contact with ICE after getting charged with low-level offenses, they are “for the most part lawful permanent residents who have been living their lives in this country,” says Laura Redman, NYLPI’s director of health justice. “And they’re stolen away from their families,” and remain a “forgotten population” in the national political debate on immigration. Even critics of mass deportation “don’t necessarily think about the space in between…when people are in detention.”

According to the NYLPI researchers, ICE and facility staff at these New York-area facilities frequently denied detainees chronic or emergency care, sometimes leading to fatal problems or irrevocable damage. Mr. Xie, a detainee with bipolar disorder and schizophrenia, did manage to obtain treatment while jailed from 2014 to 2015. But he never received proper discharge planning for treatment post-release, which triggered an incarceration of a different sort: “After two weeks without treatment, Mr. Xie suffered total psychiatric decompensation [essentially a psychological breakdown]—he was incoherent, [experiencing] hallucinations, and suicidal. He was then admitted to a hospital’s psychiatric unit where he remained under inpatient care for almost two months.”

Another detainee, Mr. Helvicta—a gay, HIV-positive rectal-cancer patient—recalled that, after detention disrupted his regular treatment regime, he asked a detention authority for help with discharge and pain, but “all he gave me was some cream and Tylenol. They suggested the pain was due to exercising. Overall, I feel like you fear for your life and have to be careful about what you say.”

In response to scores of deaths among immigrant detainees, mostly under the Bush administration, Homeland Security has tried to reform its health-care practices with four revisions of standard-practice guidelines between 2000 and 2011. However, these guidelines remain largely voluntary, and many facilities have lagged in adopting the most recent advisories, according to NYLPI, and “many facilities are only required to follow the earlier and less robust iterations.”

The undocumented immigrants profiled in NYLPI’s report were detained from around six months to a year, and in some cases as long as three years. This kind of drawn-out detention during deportation proceedings also reflects national trends of detention that may last months or years because of clogged court dockets, systematic lack of legal counsel, and regular denial of bond.

The vast majority of the cases “eventually are either released on bond [or] win their immigration proceedings,” with few ever being actually deported.

Since immigrants generally readily follow court orders and pose no “security” issue or “flight risk”—advocates cite an overwhelming rate of compliance with bond procedures—critics believe detention should almost never be used, and that immigrants facing deportation proceedings should be allowed to post bail. And Redman argues that no one with a serious health condition should be arbitrarily incarcerated and potentially cut off from care. For those currently detained, she argues, ICE and local operators must provide “constitutionally adequate healthcare.” And the longer the detainees languish, “you’re causing more damage to them, to their communities and their families.” Even if they escape deportation, when they are released to their communities they often “struggle there to then regain…the lives that they had before,” as detention has upended their jobs and destabilized their households.

In more severe cases of abuse reported in recent years, ICE officers have been accused of brutally disciplining detainees with solitary confinement or withholding food and medical care from detainees who protest about their conditions. ICE has continually disputed such claims (and has not responded to a request for comment), but a wave of hunger strikes erupting at detention centers nationwide in recent months reflect an epidemic of impunity and unrest in both public and private detention facilities, along with their private health-care contractors.

Trump’s new enforcement policies have drastically broadened the range of pretexts for which ICE can round up and detain people: With little known about the fate of the most recently arrested 680 immigrants, Redman says, it’s not even clear whether the roundups have formally “expanded to people who have just been charged or people who are working, or people have entered without documentation,” or even family members snagged in “collateral” arrests in household raids.

But ICE has clandestine allies as well. Despite a nominal policy of non-cooperation with ICE operations, rights activists say ICE enforcers feed off the NYPD’s zero-tolerance, aggressive policing of communities of color. Even even a nonviolent minor violation like driving while intoxicated can be absorbed into centralized crime databases, and if Homeland Security snatches the data when scouring for “deportable” cases, ICE agents can send officers directly into communities, even without logistical assistance from local cops. Criminal records littering black and brown neighborhoods become tinder for ICE’s scorched-earth crackdown.

So is there anything residents of a so-called sanctuary city can do to sever ties with ICE’s dungeons?

ICE requires community cooperation to use local prisons. Essentially, ICE has secured the consent of local departments of corrections and county authorities, Redman says, which “are answerable to their communities just like any other agency.” If there is grassroots opposition, “the local community where the facilities are located can absolutely rise up and move and put pressure to have these shut down”—as the people of Santa Ana did last year, when the City Council was pressured to move to shutter the local ICE jail.

Ejecting ICE jails from the New York region wouldn’t stop the agency from carrying out its enforcement drives nationwide, but it would help make good on a promise that this city made to itself long ago: to be a safe harbor for all.