Defense attorneys entered the plea on behalf of Otty Sanchez, 33, and it was accepted shortly thereafter as part of an agreement with prosecutors.

Scott Wesley Buchholz-Sanchez was three weeks old when authorities who received a frantic 911 call from the boy’s aunt arrived to find his mutilated body, and Sanchez wailing the devil made her do it. On the call, Sanchez can be heard screaming, “I didn’t mean to do it! He told me to!” while her sister pleads for an ambulance.

“This was probably one of the most horrendous cases that we have seen as far as the murder of a child,” said County District Attorney Susan Reed.

Sanchez was charged with capital murder and was found competent to stand trial. But Reed said after three examinations by separate doctors determined she was legally insane when she killed her son, the court had no choice but to accept the plea.

“She will be committed until the court decides she is not a danger to herself or anyone else,” Reed said.

Reed said she was horrified by what Sanchez did, but also disturbed by the fact that she had sought treatment before killing her son and did not receive the care she needed.

Sanchez periodically sought treatment for mental illness before her son was born and even spent a few hours in an emergency room after the birth because she was hearing voices less than a week before the attack.

Defense attorney Ed Camara said she had been prescribed the antidepressant citalopram after giving birth but had only taken it the day before killing her son. The drugs do not take effect for a few weeks.

An estimated 1,000 women are afflicted with postpartum psychosis. Women with the diagnosis can suffer dangerous delusions and desires to hurt their children, unlike postpartum depression, which occurs in as many as one in five new mothers.

Andrea Yates, the suburban Houston mother who drowned her five children in a bathtub in 2001, and Dena Schlosser, who cut off her baby’s arms in 2004 both suffered from the psychosis, their attorneys said.

The justice system has come a long way since Yates was convicted and faced a possible death sentence in 2002, said her attorney, Greg Parnham.

Yates was sentenced to life in prison before her case was overturned on appeal, after which she was found not guilty by reason of insanity in 2006 and sent to a state hospital.

“I think that we have to understand as a society that this gender-based mental disability is real,” Parnham said. “New mothers sometimes experience severe depression — some of those mothers become psychotic.”