A father accused of stabbing his five-year-old son 76 times because he thought he was the devil has been found not guilty of murder by reason of mental illness.

Acting Justice Peter Hidden said on Wednesday he was satisfied the 38-year-old man, who suffers from schizophrenia and can't be named for legal reasons, had stabbed his son in the midst of a psychotic episode and he didn't realise what he was doing was wrong.

The NSW Supreme Court judge said the defence of mental illness had been made out.

The court heard the father stabbed his son 76 times on the morning of June 8, 2018, in their Sydney home after the boy's mother and grandmother had left the house.

The court heard the boy had been asleep on a mattress in his parents' room when his father went into the kitchen, grabbed a brown knife and stabbed him.

The five-year-old was wearing blue pyjamas and covered by a blanket.

Other NSW news:

When police arrived, the father told them: "I just murdered my son. I feel sick. I thought my son was the devil. Well, I know he is, but he's dead now, at least I think he is dead."

'Doomsday'

He said: "The child was trying to tear my soul apart ... I knew it was the right thing to do but I didn't know how much time we had until doomsday."

As Justice Hidden read out details of the boy's death, including how many times he was stabbed, family members present in court yelled out.

"Do you really have to say this?" one man yelled as the family gathered around a sobbing woman.

Justice Hidden adjourned the court for a short time.

When the 38-year-old was taken back into custody his family called out that it was OK, that they loved him and it was not his fault.

No mental health beds

The court previously heard the man was diagnosed with schizophrenia in 2003 and two days before the boy's death, his mother and partner had tried to have him admitted to hospital but were told there were no beds available.

Days before that, the man admitted to having thoughts that his son was the devil, with the child's grandmother telling a mental health clinician she had trouble sleeping at night.

"I worry that I will wake up and find my grandson dead," she said, according to the clinician's notes.

The woman's worst fears were realised when on June 8 when she found the boy lying face down on his bed.

Justice Hidden said the grandmother had turned to her son and said: "My god, what have you done?"

She carried the boy out to a car and drove away before pulling over, calling for help and beginning CPR.

The boy was taken to the Children's Hospital at Westmead, where he was pronounced dead.

'Please don't hurt him'

When the grandmother was asked who had hurt the boy she told emergency services it was her son but begged them: "Please don't hurt him."

The reports of two respected forensic psychiatrists were tendered to the court with one doctor of the opinion the man had been acting under a "delusional belief" his son was the devil.

Justice Hidden said on Wednesday it was a "tragic case".

The father will be held in the mental health screening unit for an indefinite period.