A Houston prosecutor was fired Friday after he allegedly refused to bring charges against a man accused of attempted sexual assault because he believed the victim was living in the United States illegally.

Harris County District Attorney Kim Ogg fired John Denholm after he had been reassigned to a different part of the office pending an investigation of the Oct. 31 incident, The New York Times reported.

“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 had been with the office since January 2017 and is a retired Harris County Sheriff's deputy, KRIV-TV reported. He was questioning an officer who was present inside a Houston jail when Karl Bonner, an inmate suspected of drunk driving, allegedly tried pulling another inmate closer while exposing himself in a holding cell.

FIRST TEXAS DEPUTY ALLOWED TO WEAR TRADITIONAL TURBAN AND A BEARD ON DUTY HAS BEEN KILLED IN THE LINE OF DUTY

The Harris County Criminal Justice Center in downtown Houston.

The Harris County Criminal Justice Center in downtown Houston. (Harris County Courts)

The inmate screamed for help and an officer told Bonner “to get his hand off the complainant and to pull his pants up."

When Denholm spoke with the officer, he asked about the victim's immigration status, suspecting that if he was undocumented, he wouldn't come to court to testify, according to media reports.

“The district attorney, out of nowhere, says, ‘Well, is the complainant illegal?’" Joe Gamaldi, president of the Houston Police Officers’ Union, told The Washington Post on Thursday. "He goes, ‘Because if he’s illegal, I’m not taking the charge.'"

Denholm's alleged actions were quickly condemned by immigration activists and law enforcement officials. Both groups demanded he be fired.

"An attempted sexual assault is a sexual assault, and the assistant district attorney who failed to file charges for this crime shouldn’t be reassigned, he should be fired because he is a racist and menace to the Hispanic community,” said Domingo Garcia, the national president of League of United Latin American Citizens, a Latino advocacy group.

“Unfortunately, sadly, a member of the district attorney’s office was more interested in this person’s status in terms of their immigration status,” said Houston Police Chief Acevedo.

On Twitter, the police union said: "Victims of attempted sexual assault should not have justice stolen from them because a high ranking DA wants to question their legal status."

In an email to the Post, Denholm said he was “aware of who made the inflammatory allegations” and suggested the officer's narrative was untrustworthy, according to the Post.

CLICK HERE TO GET THE FOX NEWS APP

Aise from the Halloween incident, Denholm also butted heads with law enforcement over his reluctance to file criminal charges.

“He historically has been challenging to law enforcement and refuses to accept solid charges,” Harris County Deputies Organization president David Cuevas told the Houston Chronicle.

Click for more from Fox26Houston.com