A judge ruled that a man accused of gunning down a New Orleans police officer in 2015 is incompetent to stand trial after the defendant halted jury selection last week by smearing feces over his face and head, eating some of it as court personnel and spectators choked and gagged.

Orleans Parish District Judge Karen Herman handed down the ruling on Thursday, the day after Travis Boys pulled the excrement from his suit pocket, where he apparently stashed it earlier in the day. NOLA.com said Herman ordered Boys to undergo a psychiatric evaluation so doctors could determine if his actions were due to mental illness or if they were his way of delaying the trial.

“Erring on the side of caution, I’m declaring Mr. Boys incompetent,” Herman said. “I don’t want to have to do (a trial) twice.”

The Advocate in Baton Rouge reported that Boys will be sent to the state mental hospital in Jackson for evaluation. He will have another competency hearing on Nov. 30.

Prosecutors in the case filed an appeal, which they lost over the weekend. Both the 4th Circuit Court of Appeal and the Louisiana Supreme Court declined to reverse the ruling.

Herman also declined to reconsider her decision on Monday, when prosecutors introduced a recorded phone call Boys made to his girlfriend Thursday night, NOLA.com reported. Boys made the call from another inmate's account in what prosecutors say was an attempt to hide the call from investigators.

Prosecutor Inga Petrovich wrote in a motion that in the recording, Boys is “clearly aware of the circumstances going on in his case (and) makes reference to when he will be released, as well as the possible inability to call his girlfriend once he goes to the hospital.”

NOLA.com reported that Herman said Monday that state law requires that all proceedings be halted following an incompetency ruling, including new motions like the one brought to her Monday by the state. The judge did say, however, that the recording of the phone call would be sent to the doctors evaluating Boys' mental status.

Other recordings of Boys’ jailhouse phone calls will also be handed to the team working on his case.

“I’m accepting the jail tapes as authentic and providing them to the malingering team,” Herman said, according to the news site.

Orleans Parish District Attorney Leon Cannizzaro called Herman’s ruling “extremely disturbing” in a statement released last week following her decision.

"I had hoped that this court was too intelligent to allow an accused cop-killer to hijack these proceedings, but I was incorrect," Cannizzaro said in the statement, obtained by NOLA.com. "I fear that today's decision will only encourage similarly situated defendants to engage in such misconduct in the future."

Boys is charged with first-degree murder in the June 20, 2015, shooting death of Officer Daryle Holloway. The officer was transporting Boys to jail when Boys shot him inside his police SUV, the charges allege.

Boys, who police say escaped custody and was at large for about 24 hours before being recaptured, faces life in prison if convicted. He has pleaded not guilty and not guilty by reason of insanity.

Boys' defense team previously argued that he was not competent to stand trial, but Herman ruled against them last month in a hearing that lasted about six hours, NOLA.com reported. His lawyers cited his low IQ scores, a family history of schizophrenia and a 2014 incident in which he jumped from a second-floor window, breaking his ankle, as signs of his mental incompetency.

Billy Sothern, one of Boys’ defense attorneys, again argued on Thursday that his client is not competent to aid in his own defense. In his argument, he recounted the disturbing details of Boys’ actions in front of potential jurors.

"He was between us, less than a foot away from each of us," Sothern said, according to NOLA.com. "I began to smell something, turned to my right to see Mr. Boys smearing feces on his face and hair, and eating feces from his fingers."

Herman at that point saw what Boys was doing and cleared the courtroom, Sothern said. Boys continued to eat excrement off his hand and, when his lawyers tried to talk to him, he appeared “unable to focus on (them) or even appear to listen,” the lawyer said.

Sothern said that Boys later told doctors he was told about what he did in court, but that he did not remember doing it, NOLA.com reported.

Witnesses for the prosecution on Thursday tried to show that Boys' actions were part of a calculated plan to avoid prosecution. Dr. Rafael Salcedo, one of the doctors who previously observed Boys and declared him competent to stand trial, testified that he "absolutely" believed the incident was orchestrated to delay the trial, NOLA.com said.

Sheriff’s Office attorney Blake Arcuri testified that the plastic bag from which Boys pulled the feces appeared to be a bag from the jail commissary. Surveillance footage from the jail appeared to show that Boys filled the bag before he was taken to court that day.

NOLA.com reported that Petrovich argued that Boys smuggled the feces into court and waited to pull it out of his pocket when he believed it would result in his trial being delayed.

Herman said in her ruling that the defendant’s actions and the subsequent media coverage had likely tainted a potential jury.

The judge said Thursday that Boys, if found competent by the doctors assigned to assess him, may have forfeited his right to sit in the courtroom during his murder trial.

“What happened yesterday will not happen (then),” Herman said.