Though Mr. Gilbert’s histrionics may support the defense theory that he is unhinged, under state law a person can be found competent to stand trial even if they have some symptoms of mental illness, so long as a judge determines — usually based on the testimony of psychiatrists — that he or she understands the charges and the court proceedings.

James Cohen, an associate professor at law with Fordham University, said it is rare for a defendant to remain delusional over an extended period of time, once given medication.

“You have to be really ill with a mental illness that is very difficult for medication to shake,” he said.

The legal standard for an insanity defense — which Mr. Levine is expected to present — is so difficult to meet that few defendants who use one prevail at trial, even when they have a documented history of psychosis. In New York, defendants must prove not just that they have a mental illness, but that the illness prevented them from understanding the consequences of their actions or that what they did was wrong.

Prosecutors typically argue that the insanity claim is a ruse invented after the crime. They tend to focus on evidence that the accused person planned the killing or tried to evade capture to show he or she knew their actions were wrong.

“The defendant was fully aware of what he was doing,” said Craig Ortner, an assistant district attorney, during opening statements. “The evidence will show without a reasonable doubt that the defendant killed his father in cold blood.”