A Muslim woman disemboweled her daughter as a sacrifice to God after she became convinced the four-year-old was possessed by spirits, the Old Bailey heard.
Shayma Ali, 36, stabbed the girl up to 40 times and took out her liver while Koranic verses played in the background.
When police arrived at their east London home, Ali was heard chanting: 'I seek refuge in God from the curse of Satan'.
Ali was found covered in blood rocking back and forward in the lounge of her home, with the child's liver on the carpet.
She had become obsessed that the child, who cannot be named for legal reasons, was possessed by a Jinn, a spirit referred to in the Koran which can occupy humans and animals.
In the winter months of last year Ali developed acute transient psychosis, which ended in the killing of the child on December 16.
Duncan Atkinson, prosecuting, said Ali had become an increasingly devout follower of Islam after a trip to Egypt in 2009.
By last year she was prone to 'outbursts of aggression' towards members of her family who became concerned that her mental health was deteriorating.
'She became particularly pre-occupied by the idea of possession by a thing call a Jinn,' said Mr Atkinson.
'She removed the eyes from toys and videos, covering over the eyes on covers of DVDs and books,' he said.
'She also became obsessed with cleaning because she believed such evil spirits thrived in dirty spaces.' He said she 'talked constantly about evil spirits' and the belief that her daughter was possessed.
On December 16 last year she was alone with her daughter, who was not attending nursery because of a recent illness, at her home in east London.
Ali later told a psychiatrist she had been praying when she began to think about sacrificing a child 'as proof of her love of God'.
Mr Atkinson said: 'She became convinced God wanted her to sacrifice her own child.
'She gripped her daughter by the neck until she blacked out. She took her to the kitchen and, as she said, "just to make sure she had killed the Jinn, the evil spirits, properly I took a kitchen knife which had been lying about and stabbed my daughter".'
Police officers observed Ali repeatedly chanting: 'I seek refuge in God from the curse of Satan.' She was subsequently arrested and later charged with murder.
The court heard she called her husband and was found by family members in the lounge. The child was dead in the kitchen.
The four-year-old had suffered 28 exit wounds to her back, but many of the wounds overlapped each other, leading the pathologist to believe there had been 30 to 40 stab wounds.
She had also suffered blunt impact injuries to her head and compression to her neck.
In January this year Ali spoke to her husband and told him: 'A voice told me "if you really love Allah you would sacrifice your daughter".'
Psychiatrist Dr Philip Baker said Ali had become ill very quickly and it was 'very difficult for any action to be taken' but when she was psychotic she was capable of extreme violence.
Ali admitted manslaughter by reason of diminished responsibility. Wearing a burka she sobbed in the dock, flanked by three nurses, as she entered her plea.
Judge Anthony Morris QC ordered she be detained in a medium-secure unit for treatment without limit of time under sections 27 and 41 of the Mental Health Act.
'You were suffering from what has been described as an acute and transient psychotic disorder which clearly had been getting significantly worse over a short period of time before you carried out the killing,' he said.
'You became convinced that God wanted you to sacrifice your child and you went on to carry out the most terrible attack upon your four year-old daughter, stabbing her many, many times and then removing her internal organs.'
He added: 'One of the most horrifying aspects of this case is how quickly you lost control of yourself in that you became, in a very short period of time, somebody who was acting in a way entirely foreign to your normal manner of behaviour.
'The authorities must think long and hard before considering whether it is safe to release you, having regard to the rapidity of the onset of your acute symptoms in this case.'