Isabelle Cowley was drowned by her mother
A mother drowned her four-year-old daughter in the grounds of an Inverness hospital after attending the birth of her lover's baby to another woman.
Rachel Cowley, 43, of Shenval, Glenurquhart, cut the baby's umbilical cord at Raigmore Hospital in February.
She then walked off with her own child, Isabelle, and drowned her in a burn.
Cowley was charged with murder, but the Crown has accepted her plea to the reduced charge of culpable homicide on the basis of diminished responsibility.
Judge Lord Bannatyne, sitting at the High Court in Edinburgh, has continued the case until 28 September.
He ordered that Cowley be detained at a psychiatric hospital under an interim compulsion order ahead of sentencing.
The court heard that Cowley and Nicola Charles, 26, were both in a relationship with Christopher Everitt, who fathered the children of both women.
Advocate depute Alex Prentice QC told the court that in his view, given the accused's personality, "the domestic situation was untenable".
He added: "The birth of the new baby brought the whole domestic situation into focus and Rachel Cowley's world collapsed around her.
"The baby signified a constant tie between Chris Everitt and Nicola Charles."
Cowley, a first offender, admitted killing Isabelle in February this year by forcing her head under water and causing her to drown during an attack in the grounds of Raigmore Hospital.
The court heard that Cowley, who has a three-year-old son, and Mr Everitt had lived an alternative lifestyle. Over time a sexual relationship developed which involved the pair and Ms Charles.
After Ms Charles fell pregnant she chose Cowley and Mr Everitt as her birthing partners.
Following the birth, Cowley held the baby and a midwife noticed she seemed tense during a discussion about registering the child.
Cowley later left the ward with Isabelle.
She later appeared at a couple's home in Balloch, near Inverness, in the early hours of 23 February seeking help and claiming she was lost.
Cowley was wearing a boiler suit she had taken from a skip at the hospital.
She ran off when the police were called, but was traced by officers.
The court heard that police asked Cowley if she had hurt the girl.
She said: "I think I might have done something to her. I think she might be hurt."
Mr Prentice said psychiatrists who examined Cowley were of the opinion that she was suffering from a mental disorder, most probably a personality disorder.
Defence solicitor advocate Murray Macara QC said that all the available evidence pointed to Cowley having been "a loving and caring mother to Isabelle".
Det Ch Insp Kenny Anderson, of Northern Constabulary, said the force had noted Cowley's plea to culpable homicide.
He added: "The death of a child in such circumstances is a tragic case, devastating for the family and for everyone concerned."