Monifa Sanford, one of two Montgomery County women accused of stabbing four young siblings — two fatally — because they thought evil spirits had invaded the children’s bodies, was legally insane during the January attacks, according to a Maryland state psychiatrist.

The opinion, revealed in court Friday, increases the chance that Sanford, 22, could ultimately be committed to a secure, forensic hospital. But prosecutors also could challenge the opinion.

“She was in a delusional context when these allegations occurred,” David Felsen, Sanford’s attorney, said in court, citing the doctor’s report that he said “makes some pretty conclusive findings.”

Sanford’s co-defendant in the case — the children’s mother, Zakieya Avery, 29 — also has been evaluated by doctors, but those results have not been made public.

From the beginning, the stunning allegations underlying the case have suggested that mental illness may have played a strong role in what happened.

Monifa Denise Sanford (Montgomery County Police)

Sanford and Avery had taken to calling themselves “demon assassins,” authorities said.

Together, inside Avery’s Germantown townhouse the night of Jan. 16, they performed what they thought was an exorcism of Avery’s 1-year-old son, Norell, who they believed needed cleansing to be prepared for heaven, according to prosecutors’ presentations in previous court hearings.

Avery tried to snap Norell’s neck and choke him, according to prosecutors. When that didn’t work, she directed Sanford to get a knife from the kitchen. They killed Norell and then became convinced that spirits had begun jumping among the children. They fatally stabbed Zyana, 2, and attacked Taniya, 5, and Martello, 8, both of whom survived.

Detectives charged both women with two counts of murder and two counts of attempted murder.

The women have spent much of the past eight months locked in a psychiatric hospital undergoing evaluations.

Sanford, who stands 4 feet 8 inches tall, appeared in court Friday. She said few words, at one point responding “good morning” in a soft voice to Circuit Court Judge Cheryl McCally.

Peter Feeney, an assistant state’s attorney prosecuting the case, said his office would need two to three weeks to review the report and possibly speak with the doctor who wrote it.

In Maryland, a successful “insanity defense” yields a finding of “not criminally responsible.” The law essentially holds that people so delusional or mentally ill that they commit a crime but can’t comprehend that it’s a crime should be locked in a hospital, not a prison.

The state law reads: “A defendant is not criminally responsible for criminal conduct if, at the time of that conduct, the defendant, because of a mental disorder or mental retardation, lacks substantial capacity to: 1) appreciate the criminality of that conduct, or 2) conform that conduct to the requirements of law.”