The cry for help came from a holding cell.

A Houston police officer heard the plea on Nov. 1, turning to find an inmate standing while handcuffed to a chair and pointing to the prisoner next to him, Karl Bonner. The officer rushed into the cell and separated the two men — only to learn that Bonner had allegedly exposed himself and attempted to force the man’s face into his crotch, according to the Houston Police Officers’ Union.

But when the Houston officer called the Harris County District Attorney’s Office to press charges of attempted sexual assault, the prosecutor wasn’t interested — because he was concerned about the victim’s immigration status, the union claims.

“The district attorney, out of nowhere, says, ‘Well, is the complainant illegal?’ ” union President Joe Gamaldi told The Washington Post on Thursday. “He goes, ‘Because if he’s illegal, I’m not taking the charge.’ ”

On Friday, Harris County District Attorney Kim Ogg fired the prosecutor, John Denholm, after Houston officials widely condemned his comments and feared the incident could strain the fragile relationship between law enforcement and the immigrant community. Earlier this week, a police officer presented the victim’s case to a different prosecutor — and records show that the 44-year-old Bonner, already facing DWI charges, now also stands charged with third-degree attempted sexual assault. It was not immediately clear whether he had an attorney.

“It is wrong to ask about a victim’s immigration status; it is against our policy, and it won’t be tolerated,” Ogg said in a statement. “We treat everyone equally under the law, no matter how they came to be here.”

Denholm’s firing comes after two law enforcement unions, at least one state lawmaker and the League of United Latin American Citizens, a national Latino advocacy group, insisted that disciplining or reassigning Denholm was not enough and that he needed to be terminated. Houston and other cities have taken steps in recent years to assure undocumented immigrants that it is safe to report crimes, Gamaldi said. Their immigration status, he said, is never supposed to matter.

The officer who witnessed the incident never asked the alleged victim’s immigration status, Gamaldi said, and yet Denholm refused to accept the charges after learning that the victim had a Mexican Consulate identification. Denholm then suspected the victim was in the country illegally and that he would not come to court, Gamaldi said.

“Obviously, as police officers, we’re completely disgusted with this because we’ve worked so hard to bridge the gap with the Hispanic community, whether documented or undocumented,” Gamaldi said. “If the Hispanic community or any other type of community doesn’t feel comfortable coming to us, it’s going to make them prey for predators who know the district attorney’s office isn’t going to do anything with these charges.”

Earlier Friday, in an email to The Washington Post, Denholm said he was “aware of who made the inflammatory allegations” and appeared to suggest the police’s narrative was untrustworthy.

In the wake of President Trump’s promises to deport unauthorized immigrants en masse, liberal jurisdictions across the country have sought to cut ties with U.S. Immigration and Customs Enforcement and strengthen relationships with immigrant communities so they are less likely to be deterred from reporting crime.

In 2017, Harris County Sheriff Ed Gonzalez terminated a controversial program called 287(g), which allowed deputies to cooperate with ICE from jail. And Houston Police Chief Art Acevedo was an outspoken critic of the state’s “anti-sanctuary cities” law passed that same year, promising immigrants that his officers would never indiscriminately demand that people “show me your papers.”

That’s why Acevedo said he found Denholm’s actions “beyond disappointing.”

“When the criminal justice system fails to protect an undocumented immigrant from criminals, or administers justice in a discriminatory way,” he said in a statement to The Post on Thursday night, “we place all segments of our community” at risk.

When she took office in 2017, Ogg had handpicked Denholm to join her administration in a high-ranking position in the intake bureau, where prosecutors decide whether to file charges. Before that, Denholm spent more than 20 years in the Harris County Sheriff’s Office — but even his former colleagues called for his firing.

The president of the Harris County Deputies Organization told the Houston Chronicle that law enforcement has generally had problems with Denholm, claiming he sometimes “refuses to accept solid charges.”

State Rep. Gene Wu (D) said Thursday that “Denholm must go,” calling the situation “intolerable,” while the League of United Latin American Citizens said it feared Denholm’s actions would have a chilling effect within the Hispanic community.

“The actions of the DA’s office has sent a clear message to our local Hispanic community: ‘don’t report crimes because you don’t count,’ ” Alfonso Maldonado, a regional director for the organization, said in a statement Thursday.

Gamaldi applauded Ogg’s decision to fire Denholm on Friday but said more work lies ahead to undo any damage Denholm’s actions may have caused.

“Finally DA Kim Ogg did something to address this abhorrent act by one of her hand picked, top appointments,” he said on Twitter. “Now the real work [begins] of re-building the trust between the criminal justice system and our Hispanic community.”