At 20 years old, Michael had the look and build of a much younger person. Across the back room of a dusty Harlem police precinct in 2010, I could see defiance and fear in his eyes. I suspected that he did not yet understand the stakes. Deportation was the last thing on his mind.

A few hours earlier, a detective had called Michael, summoning him to the precinct to answer a few questions. My students and I had been representing Michael for a few months, so we went with him. The staff had us wait in a side room, where we learned that Michael’s ex-boyfriend had accused him of stealing his cellphone.

As the detective deliberated over whether to arrest him, Michael’s anger bubbled over. “It’s not true,” he said, his voice rising. Michael had paid for the cellphone, and when he and his boyfriend broke up, he had taken it back. Michael began furiously texting his ex.

“You shouldn’t contact him until we sort this out,” I whispered. I wondered whether Michael’s ex realized what he had set in motion by calling the police.

Michael already had a criminal record comprising a handful of minor charges. Shoplifting, for when he and a friend were found with two hats in a department store. Fare evasion, for when he got pulled out of the subway for using a student-rate MetroCard even though he was not in school. Petty crimes had led to two misdemeanor convictions.

Given everything Michael had gone through in his young life, I was surprised his record wasn’t more serious. Thrown out of his home as a teenager after his mom found out he was gay, Michael joined the roughly 1,600 gay, lesbian, bisexual, and transgender kids who live on the streets of New York City. Homeless LGBT youth are vulnerable to violence, hunger, and drug addiction. Six out of 10 consider or attempt suicide. With social workers, shelter space, and other interventions in short supply, homeless LGBT youth in New York City are much more likely to come into contact with police than with any other government agency.

Michael’s misdemeanors were clearly acts of survival. But rather than getting help, he got a criminal record. So far he had managed to avoid jail time, getting community service or a small fine for his offenses. But this time was different. Stealing a cellphone could be charged as grand larceny—a felony punishable by up to four years in jail. If the police pursued the charges, they would hold Michael at the precinct overnight, and a judge would decide whether or not to set bail in his case the next day. If the judge set bail, Michael would need someone to post it right away. Lacking family to post bail, he would likely be sent directly to Rikers Island, New York City’s most notorious jail.

The idea of Michael in Rikers, scared and alone, was terrifying. The violent and abusive conditions there are horrific. But that wasn’t Michael’s only problem. For decades, immigration agents had operated a small office at Rikers, scouring the population of pretrial and sentenced individuals alike for deportable immigrants. It was one of many programs that federal immigration officials used to turn the criminal legal system into a pipeline for deportation.

Michael was a green card holder, a permanent resident whose relatives in Jamaica sent him to stay with his mother in the United States when he was just a kid. The convictions he picked up when he became homeless were minor. But immigration officials often consider even petty crimes to be “crimes involving moral turpitude.” And two such crimes were all it took to render Michael not only deportable but subject to mandatory detention while he fought his case.

If Michael was sent to Rikers, immigration agents would place a hold on his release known as a detainer. He would remain in Rikers until immigration agents could take him into immigration custody. In other words, if Michael went to Rikers, the only way he was leaving was in chains. Even if we posted bail in his criminal proceedings, immigration agents would send him to an immigration jail, where he would be ineligible for release. And there he would stay—fighting deportation to Jamaica, where being gay is a crime.

Federal immigration officials proudly describe the criminal legal system as a force multiplier for deportation. Since the punitive overhaul of immigration law in the 1980s and ’90s, the federal government has used local police, prosecutors, criminal courts, corrections, probation, and parole departments to identify and deport more people than federal immigration officials ever could alone.

What emerged was a new infrastructure for deportation. Immigration officials rolled out program after program—notably the Criminal Alien Program, Secure Communities, and 287(g)—justifying each on the basis of public safety. These programs, they claimed, would target the worst of the worst. In reality, the programs ensured that any immigrant who comes into contact with the criminal legal system gets on a fast track to deportation—including people who never end up being convicted of a crime or who receive only minor records.

The resulting crime-based deportation machine is designed to extract maximum suffering from someone like Michael. Being black, gay, and homeless already leaves him vulnerable to severe biases in the criminal legal system. Being all of those things and an immigrant extinguishes what little fairness and equity might be left. At every stage of criminal proceedings, the threat of deportation narrows his choices, making it more difficult for him to pursue a just result. And even if he gets through his criminal proceedings without being funneled into the deportation pipeline, the threat of deportation still lurks around the corner.

All of this is by design. Ever since the immigration and criminal legal systems merged, escape from the deportation pipeline has been the exception, not the rule. Draconian laws, harsh programs, and human failings weld together to ensure the perpetual punishment of millions, and any semblance of justice crumbles in the process.

At the precinct, the detective warily eyed me and the law student who had been waiting with Michael for the past two hours. He had hoped we would have given up by now. We had been trying to explain why Michael shouldn’t be formally charged. We debated whether to disclose that Michael was at risk of deportation. It was always a calculated risk, and in most parts of the country you wouldn’t bring it up. Many officers would simply pick up the phone to call ICE if they thought they had someone who was deportable. But some officers could be sympathetic. It was clear that Michael was young and caught up in a bad situation. The police, like everyone in the criminal legal process, had some discretion.

But telling the officer was no use. “We’re taking him in,” the detective declared. The charge was, as we feared, grand larceny.

I put my hand on Michael’s shoulder. The waiting had worn on him, and he was angry at his ex. The detective led him toward the holding cells at the back of the precinct.

We began what was a familiar routine in cases like Michael’s: frantic calls and emails to local public defenders’ offices to see who might be at the next day’s court hearing. We had to make sure the criminal defense attorney understood Michael’s immigration history. Michael couldn’t plead guilty to grand larceny, and he couldn’t go to Rikers.

At the time and place of Michael’s arrest—2010 in New York City—the biggest deportation threat came from ICE’s Criminal Alien Program. The program facilitates partnerships and data collection between federal immigration officials and state and local corrections departments across the country to identify immigrants for deportation. Rikers had partnered with immigration officials for decades. Immigration agents would interview people in the jail, often without identifying themselves, and after gathering information, the agents would issue a detainer—an “immigration hold” that kept the person in custody for deportation.

In the five years preceding Michael’s latest arrest, Rikers had handed over 13,000 New Yorkers to ICE through the Criminal Alien Program. Nationwide, the number was in the hundreds of thousands. It was the first major program that made the identification and deportation of “criminal aliens” a priority, transforming the criminal legal system in the process. But it would not be the last.

The spark that lit the fuse for the explosion of crime-based deportation programs came in 1986. New York Republican Senator Alfonse D’Amato had lambasted federal authorities for a so-called “criminal alien problem.” Congress directed the Immigration and Naturalization Service to identify immigrants in jails and prisons for deportation. In response, the Criminal Alien Program was born.

Originally called the Alien Criminal Apprehension Program, the initiative took a boots-on-the-ground approach to federal and local cooperation. It sent federal immigration agents to local jails and prisons to check the names of incarcerated people against the federal immigration databases. If they found someone who might be deportable, they would issue a detainer, which directed the local jail or prison to notify the INS of any upcoming release date so that the individual could continue to be held for immigration custody.

These efforts only whetted Congress’s appetite for more inquiries into the “criminal alien problem.” At a Senate hearing devoted to the topic in 1995, Delaware Republican William Roth presented a report that estimated that there were 450,000 immigrants in jails and prisons, some of whom the INS failed to identify. It described these individuals as having committed serious crimes that were often connected to “their illegal situation.” The report ominously theorized about their “‘outlaw’ status, often leading them into the shadowy realms of criminal lifestyles.” Although numerous studies had debunked any correlation between immigrants and increased crime rates, many members of Congress accepted the narrative and demanded to know why more “criminal aliens” were not being deported.

The INS blamed a lack of financial resources, and the report concurred that more federal funding was needed. But the report also pointed to the INS’s poor record-keeping. Name-based and decentralized, INS records were often unreliable or unavailable, leading agents to miss deportable individuals during screenings. And because those screenings were limited to jails and prisons, people at other stages of the criminal process—such as those sentenced to probation—were often overlooked.

Expanded biometrics became the solution. Whenever the INS encountered an immigrant, federal officials began collecting fingerprints and placing them into a more centralized system. The system allowed the INS to match those records against any fingerprinting systems run by local law enforcement and collected, in part, by the FBI.

In the 1990s, however, biometrics collection was a painstaking process. Millions of older immigration records lacked fingerprint data, and not all local jurisdictions had the capacity or desire to pool their fingerprinting records for deportation purposes.

Those gaps began to close in 2008 when the George W. Bush administration announced Secure Communities, a pilot program in which fingerprints taken during the local arrest and booking process were automatically shared with the Department of Homeland Security, which had taken over many of the responsibilities of INS in 2003. The data sharing triggered a review of immigration records, and if the person was deportable—either because of undocumented status or a criminal record—ICE could issue a detainer asking the local jurisdiction to hold the person instead of releasing her on bail or at the end of her criminal case and any sentence.

Given the number of people who were potentially deportable—an estimated 11 million who were undocumented and some unknown percentage of the 14 million authorized immigrants who may have been deportable on criminal grounds—not everyone could be detained and processed for deportation.

So the Department of Homeland Security prioritized: “Criminal aliens” went to the top of the list, and Secure Communities became a way to ensure their deportation. ICE billed the program as a “historic opportunity to transform immigration enforcement and improve public safety by focusing on those aliens who pose the greatest threats to our communities.”

When President Barack Obama came into office, he expanded Secure Communities. In unveiling ICE’s strategic plan for the rollout, federal officials repeated the justification from the Bush administration: Secure Communities would allow ICE to “prioritize enforcement actions on those posing the greatest threat to public safety.” By linking local fingerprinting data to federal databases, ICE could better target “criminal aliens” for deportation.

During the initial expansion, the Obama administration suggested that localities could choose whether to join the program. Many signed up. But soon enough, studies began to reveal that a large number of people targeted through the program had minor criminal convictions or none at all. Secure Communities had become a dragnet for deportation.

Some localities responded by declining to participate in the program. Eventually several larger jurisdictions, including the states of New York, Illinois, and Massachusetts, opted out entirely. That’s when ICE revealed that participation was not optional. Localities could not, it argued, pick and choose which federal agencies could have access to their fingerprinting data or for what purposes. Since all localities chose to share their data with the FBI to screen for open cases and criminal history, participation in Secure Communities was part of a package deal. By 2013, Secure Communities was operational in every jurisdiction in the country.

If Secure Communities had been in place in New York City at the time of Michael’s arrest, his fight to stay off ICE’s radar screen would have been over before it began. That’s how Secure Communities works—a fingerprintable arrest is all it takes. It does not matter if the criminal charge is eventually dismissed. It does not even matter if the arrest was illegal—based on unconstitutional racial profiling, for example, or a corrupt police officer. The point of Secure Communities is to piggyback on any arrest.

Many of the localities that had attempted to opt out from the fingerprint-sharing aspect of Secure Communities at the front end now pivoted to challenge the detainer practices at the back end. What authority, immigrant advocates argued, does a city or state have to hold someone after his release date just because ICE has requested it? In such cases no judicial warrant accompanied the detainer, and the detainer provided no process for people to challenge whether it was valid. Once people began successfully suing federal and local officials for what amounted to warrantless arrests, ICE was forced to admit that detainers were simply voluntary requests. It was up to localities whether to honor them.

The mounting pressure from immigrant communities prompted some cities and states to pass “sanctuary” legislation, which officially prevented local police or corrections officers from holding immigrants on detainers in the absence of a judicial warrant or other requirements. Some jurisdictions went even further, preventing ICE from gaining access to their jails. The New York City Council, for example, kicked ICE out of Rikers and all other city jails in 2015.

True to form, ICE simply changed its tactics. In sanctuary cities, ICE expanded its operations to target “criminal aliens” through more home raids, courthouse arrests, and other forms of immigrant policing. It launched Operation Safe City, a massive series of community raids targeting sanctuary cities in 2017. ICE did not hide its retaliation. “Sanctuary jurisdictions that do not honor detainers or allow us access to jails and prisons are shielding criminal aliens from immigration enforcement and creating a magnet for illegal immigration,” ICE Acting Director Tom Homan said in a statement. “As a result, ICE is forced to dedicate more resources to conduct at-large arrests in these communities.”

Despite pockets of local resistance, Secure Communities continues to give ICE what it desires: the name and criminal history of any community resident who comes in contact with the criminal legal system. With that kind of access, even in sanctuary cities, there is no true sanctuary from deportation.

By giving ICE access to people, spaces, and data from local jails and prisons, programs like the Criminal Alien Program and Secure Communities provided the basic structure for an arrest-to-deportation pipeline in the United States. But they are not the only tools that ICE uses. As bad as things have been for immigrants like Michael in places like New York, the situation has been much worse in parts of the country where local police have engaged in immigration enforcement of their own.

Immigrants like Juana Villegas saw firsthand how bad it could get. In 2008, she was driving through the small suburban town of Berry Hill, Tennessee, when a flash of lights and a siren alerted her to a Davidson County police car behind her. Juana pulled over. The officer asked for her license and registration. Being undocumented, she had neither. The officer promptly arrested her for a misdemeanor traffic offense and took her to Davidson County Jail. Most people would be released from jail to fight a traffic charge in court. But Davidson County had recently entered into a 287(g) agreement. Named after a section of the Immigration and Nationality Act, a 287(g) agreement permits the federal government to deputize local police and corrections officers as immigration agents. Although 287(g) had been on the books since the harsh immigration law reforms of 1996, no locality took the federal government up on its offer to enter into a 287(g) agreement until after September 11, 2001.

Juana had no criminal record before her arrest. But she was undocumented. Armed with their 287(g) agreement, Davidson County officials decided to keep her in custody so that ICE could pick her up for deportation.

Juana was nine months pregnant. Three days into her custody, her water broke. Rather than release her, Davidson County officials continued to honor the ICE detainer request. Police officers took her to a local hospital, shackled her leg to the bed during delivery, and then returned her to jail without her baby or a breast pump. As her baby developed jaundice and she developed a breast infection, local law enforcement kept her in custody. Two days later, she was taken to criminal court, where she was sentenced to time served for unlicensed driving and released pending deportation proceedings.

Juana fought back. She spoke out against her treatment and the practice of shackling incarcerated women during labor. She sued Davidson County, and six years after her arrest, she received a special visa to remain in the United States with her son.

Juana’s treatment shocked the conscience of Davidson County. The county withdrew from the 287(g) agreement in 2012—using Secure Communities as cover for why the agreement was unnecessary—and paid a six-figure settlement for shackling Juana. Her victory was a rare one. If it weren’t for legal intervention, she would have disappeared into the deportation pipeline like millions of others.

People with minor criminal records are routinely targeted by the arrest-to-deportation pipeline. A 2011 study of 287(g) programs demonstrated that roughly half of the people issued detainers through the program were convicted of misdemeanors or traffic offenses. A 2012 study of Secure Communities revealed that more than half of people deported through the program were convicted of misdemeanors or traffic offenses, or had no conviction at all. And a 2015 study of the Criminal Alien Program demonstrated that the vast majority of people deported through the program—80 percent—had either no conviction or a minor conviction.

By piggybacking off the criminal legal system, these programs transform routine encounters with local police into deportation cases for millions of people living in the United States. And contrary to public messaging, federal immigration officials are well aware that this system has little to do with public safety and everything to do with widening the deportation pipeline.

With every year that passes, the criminal and deportation systems become more tightly intertwined. Whether in a federal courthouse in Texas or a state criminal court in New York, people of color who lack immigration status find themselves staring down a double punishment, with few safeguards to protect them. A few might find a way to break out of the pipeline—but more often than not, deportation is the end result.

Michael emerged as one of the lucky few. His public defender understood what was at stake, and worked with Michael and with us to protect him from deportation consequences. She secured his release on bail before ICE could issue a detainer. After what felt like endless court dates and stalled conversations with the District Attorney’s office, the charges against Michael were dismissed.

Michael was able to avoid a conviction that could have sent him to an immigration prison and eliminated his ability to fight deportation. But the fear remains. There is no statute of limitations for deportation. It can come back to haunt a person at any time. Michael can do everything the criminal legal system expects of him and more—and it still may never be enough.

Only citizenship can truly provide immigrants like Michael with freedom from the threat of deportation. But the process of citizenship, like everything else in the immigration system, requires scrutiny into a person’s criminal record. Michael was eligible for citizenship, but in ICE’s view he was also deportable. In those cases, you can guess which process the immigration system prioritizes. This is one of the reasons many people delay the process of applying for citizenship—they prefer to wait for a time when they can clean up their record or have a better defense against deportation if necessary. In the meantime, they remain vulnerable to the deportation pipeline.

As a lawyer, I fear the midnight call from clients like Michael, people who are heavily policed because of what they look like or where they live. Another arrest, another charge. The old criminal record comes back to life as a new criminal case begins. Success depends on the existence of so many actors beyond the person whose life is at stake: a zealous defender, a sympathetic prosecutor, a reasonable judge. Without them, will we find a way to prevail? If not, the pipeline will work as it was intended. It will thrust people into cages, just long enough to banish them permanently.