A mother who took her 3-year-old son for an exorcism and a father who has been in and out of jail will lose their parental rights, a state appellate court decided this week.

The ruling upholds an earlier decision by the  Division of Child Protection and Permanency, and opens up the possibility foster parents can adopt the couple's two children — now ages 6 and 7, identified in court papers by the fictitious names Mala and Jack.

According to the appellate court ruling, the mother, identified as "J.G" by the court, believed she was hearing voices and took her then-3-year-old son to a priest for an exorcism.

"Mother was homeless and the children had reportedly not eaten in three days," the court wrote. "She reported hearing two voices, a 'good one' and a 'bad one,' and having to resist the urge to give her children to the devil."

The children were taken to a foster home as their father was in prison and no other family member was available.

After the mother was hospitalized four times in a psychiatric hospital, failed to take her medication, failed to attend parenting classes and was jailed for receiving stolen property, the state tried to strip the parents of their parental rights, the ruling states.

The father, upon his release from prison, had several "positive" visits with his kids but returned to jail after testing positive for cocaine used and then jailed again for public drunkenness, it states.

The children's foster mother wished to adopt the children but the parents protested, claiming the state had not fully proven their case.

The court in its decision disagreed, stating that the their case was "amply supported"  with "clear and convincing evidence." It said the children's father knew about the mother's psychiatric problems, "yet did nothing to ensure the children's safety and stability" — and instead landed himself in jail multiple times, refusing to take steps to treat his addiction and failing to secure employment long enough to provide for the,