The focus of the Etan Patz murder trial on Thursday shifted from the 6-year-old's 1979 disappearance to past cocaine use and domestic violence involving defendant Pedro Hernandez, and the judge's decision to allow testimony about that behavior.

After keeping it secret from the jury and public for weeks, Manhattan Supreme Court Justice Maxwell Wiley unexpectedly ruled Tuesday that prosecutors could bring up Hernandez's past misbehavior, and they used the opportunity to challenge a defense psychiatrist's conclusion that he has a mental disorder.

"Any time he says he had a visual hallucination, you have to consider whether he was using cocaine at the time, correct?" prosecutor Penelope Brady asked Dr. Michael First, the defense expert, at one point.

More storiesComplete coverage: Etan Patz case

Etan disappeared on his way to catch a school bus in SoHo. Hernandez, 53, of Maple Shade, New Jersey, confessed to police in 2012 that while he was a teen working at a SoHo bodega, he lured the boy into the store basement and strangled him.

The defense contends Hernandez falsely imagined that he committed the crime. First diagnosed him with schizotypal personality disorder, a "mild" form of schizophrenia, but acknowledged that Hernandez also had a 20-year cocaine habit that began in the mid-1980s, and hit his wife in fights over money.

While prosecutors peppered the psychiatrist with questions about whether Hernandez could have trumped up his claim of mental problems, defense lawyer Harvey Fishbein continued to complain that the judge's ruling torpedoed a fair trial.

advertisement | advertise on newsday

Earlier this week, before Wiley switched direction, Fishbein called Hernandez's daughter Becky as his first witness. She described her father's history of strange behavior and visions -- but did not mention anything about drugs or assaulting her mother -- because the judge had excluded them.

After Brady questioned First on Thursday about Becky Hernandez knowing about her father's drug use, Fishbein said prosecutors were trying to make the daughter look like a liar who misled the jury, when the problem was that the judge had made a new ruling.

"The jury has to be wondering why didn't Becky say anything about cocaine," he told Wiley. "Well, it's because the defense was sabotaged."

Get the Newsday Now newsletter!

The best of Newsday every day in your inbox.

The defense fears evidence of drug use and assaults will bias jurors against Hernandez. In addition to challenging the confession, the defense also plans to try to incriminate a convicted pedophile who lived in SoHo and was long suspected by law enforcement.