A man stabbed his girlfriend and their daughter before fleeing and leaving the couple's other child locked in their house for 30 hours, a court has heard.
Anthony Marsh, 22, knifed Stephanie Bellinger, 24, more than 30 times at their home in Totton, near Southampton, in February, a jury was told.
Winchester Crown Court heard 10-month-old Lili was also stabbed.
Marsh has admitted the killings on the grounds of diminished responsibility but denies murder.
The jury heard Marsh did not kill the couple's two-and-half-year-old son, instead fleeing the house.
Ms Bellinger's mother and sister broke into the family home after becoming worried and were confronted by a "truly distressing scene", the court heard.
Marsh was arrested a few days later in nearby Fareham and told police he heard voices telling him to kill Ms Bellinger.
The court heard he went downstairs, got a knife and attacked his partner who was asleep.
He then tried to suffocate Lili, "because the voices told him to", but said he could not remember stabbing her.
The court heard Marsh told police the voices told him to kill his other child but he was able to resist.
Prosecuting, Christopher Parker QC said Marsh had been diagnosed with bipolar disorder after taking drugs as a teenager but had never mentioned hearing voices to doctors.
He had also regularly fled the family home before handing himself in to hospital A&E departments after sleeping rough, he said.
Mr Parker told the jury the diagnosis was a "convenient label for his behaviour".
The court heard Ms Bellinger had been worried and supportive of Marsh and outwardly they seemed happy.
But they were £13,000 in debt in part because Marsh had lost his job as an assistant manager at a pub when he stole £2,000.
The jury heard Ms Bellinger's body had been "left as if she was a victim of a sexual assault" and it was "indicative of a sexual type of killing and not consistent with a mercy killing".
"Something within the relationship has caused him to snap," the barrister told the jury.
"He has admitted, and does accept, that he did kill them both.
"But it is contended on his behalf that he is guilty, not of murder, but manslaughter as at the time he killed Stephanie and Lili he was suffering from a mental abnormality and it was that that substantially impaired his responsibility for these unlawful killings."
The trial continues.