Gomez insisted to me that he had never done anything unethical during an investigation, but he acknowledged that he “walked the edge” between what was permissible and what was not. “The ends justify the means,” he told me, summing up the wisdom he gleaned from Machiavelli’s “The Prince.” “Whatever I got to do,” he said, “I’m going to do it.”

In the summer of 2016, Gomez took on what would become the biggest case of his career. He claimed that a ring of corrupt cops in the 42nd Precinct of the South Bronx was terrorizing an entire neighborhood, forcing kids to implicate one another in crimes, as part of a scheme he described as a “gargantuan nightmare of corruption.” At the center of the case was a teenager named Pedro Hernandez. Over the next 14 months, Gomez brought widespread attention to Hernandez’s story in the New York press, transforming the then 16-year-old into a cause célèbre. To Hernandez’s supporters, from Kerry Kennedy to the prominent activist Shaun King, his ordeal illustrated the most egregious failings and inequities of the system. In a long essay on Medium, King declared that Hernandez’s saga was “the most painful, traumatic, outrageous, outlandish, over-the-top story of government-sanctioned police brutality, wrongful convictions” and “widespread corruption” in “modern American history.”

When Hernandez’s troubles started, he was living with his mother, Jessica Perez, and three siblings in the Morrisania section of the Bronx, a hilly neighborhood scattered with massive public housing complexes. As of 2015, Morrisania accounted for a higher percentage of the city’s jail population than any other neighborhood in New York. Hernandez’s older brother, Jesswill, was in jail, facing a murder charge for which he would later be convicted. Hernandez had been having his own run-ins with the law. Starting when he was 15, he had been arrested multiple times for a series of shootings and robberies, among other less serious offenses, and had spent time in a juvenile detention facility. But all his criminal charges were eventually dropped.

As Hernandez and Perez would later repeat in court filings, they claimed he had been unjustly targeted and framed by a group of cops at the 42nd Precinct, among them a detective named David Terrell, who specialized in gang investigations. Perez told me she first met Terrell a few years earlier, when her sons began having problems with the authorities, and since then she had had a series of disturbing exchanges with him. On one occasion, she told me, Terrell called her at home and asked her to bring some “Spanish food” to the precinct. On another, she said, he drove up alongside her and her mother and ominously said he would “break into” her before laughing and driving away. Perez said she eventually “put him on zero,” admonishing him in front of another officer to leave her alone. After that, she said, she began seeing Terrell in the lobby of her building, talking to her neighbors in what she felt was an attempt to work up some bogus justification for arresting Hernandez. (In a continuing lawsuit, Terrell asserts that he never had any “personal involvement” with Perez, and his lawyer called the accusations “laughable”; a lawsuit Perez and Hernandez filed against Terrell, other officers, the City of New York and a district attorney was dismissed. Hernandez has since filed a new lawsuit.)

In July 2016, Hernandez was charged in connection with another shooting and was sent to Rikers Island, where New Yorkers who can’t afford bail are typically jailed while awaiting trial. In the past, Hernandez’s family had been able to pool together enough money to bail him out. This time, the prosecutor, claiming that Hernandez was a violent gang member and a “scammer” with access to large amounts of cash, asked the judge to set the bail high enough to keep him inside. The judge obliged, settling on $250,000 — an unusually high sum for even a violent crime. On her next visit to Rikers, Perez had to tell her son that she couldn’t afford to bring him home. “That was the day that he first told me, ‘I can’t be in jail, this is making me feel like I want to die,’ ” she told me. “I came home, and I had two options. Have the same feelings with him — he wants to die, I want to die, too. Or get mad about it and do something about it.”

Perez called Gomez, whom she had seen on television. Gomez says he was initially skeptical when Perez told him her son’s story. Would rogue cops really conspire to arrest the same kid again and again for crimes he didn’t commit? “It was too outrageous,” he said. “Too out there.” But after meeting Hernandez, Gomez was convinced of his innocence. “He didn’t have that street look, like a thug or criminal,” he told me. “He was just very family-oriented. You could see that. You could feel it.” Hernandez told me that he was “not a saint,” but he added, “I wasn’t the worst kid outside in the streets either,” and he insisted that he hadn’t committed any of the crimes for which he was charged.