A man accused of murdering a seven-year-old girl in 1992 later admitted to having sexual fantasises about naked “young girls”, a jury has been told.

David Boyd, 55, who denies murdering Nikki Allan in a derelict dockside building in Sunderland 31 years ago, has a previous conviction for indecent assault on a nine-year-old girl in 1999, Newcastle Crown Court has heard.

He also has a conviction for breach of the peace in 1986, after approaching four children, aged eight to 10, grabbing one and asking for a kiss, the court heard.

After the indecent assault conviction, which happened in a Teesside park, Boyd told a probation officer about fantasies he had previously had, but said he had grown out of them.

Richard Wright KC told the jury the probation officer said: “He initially denied ever having any sexual thoughts about children, but subsequently informed me that, when he was approximately 22, he began to fantasise about both adults and children, in particular young girls.

“He says he would think about young girls being naked and what it would be like to touch their body and have sexual intercourse with them, but describes this as a phase he was going through and something he grew out of.”

The breach of the peace happened in Sacriston, County Durham, and involved Boyd taking hold of a girl by the arm, asking to kiss her and holding on to her before letting go and telling the group “not to tell anyone”, Mr Wright said.

The indecent assault happened in April 1999 when he approached two girls aged nine and 12 who were playing in Primrose Hill Park, Stockton.

Boyd did not know either of them, asked what they were doing and he grabbed one by the shoulder, and if she was wearing knickers, told her not to scream then groped her over her clothes, before he ran off as the girls screamed.

He later told a doctor he felt guilt and shame and claimed he was “drunk and depressed and acted on impulse”.

He had told his probation officer he “began to think what it would be like to touch them” as he approached the girls and had begun to think “dirty thoughts”.

Before Mr Wright introduced these convictions, Mrs Justice Lambert told the jury they must not convict Boyd “wholly or mainly” on this evidence.

And after it had been read, the judge added: “Keep an open mind, don’t rush to judgment, wait until you have heard all the evidence in the case.”

Nikki Allan was a neighbour of Boyd’s in flats called The Garths, which have since been demolished.

She was hit over the head with a brick and stabbed multiple times in a derelict Old Exchange Building, then dragged, while dead or dying, and dumped in a corner of the basement.

Boyd, 25 at the time of the killing, and now of Chesterton Court, Stockton, Teesside, was known to Nikki’s family, as his then girlfriend was a babysitter for her mother.

The trial continues.