A 13-year-old boy who had been neglected by his mother and developed a pornography addiction has admitted raping a girl aged under eight.
Mold Crown Court heard how the boy was allowed to spend hours looking at extreme indecent images online.
The court heard how he used the girl to act out his sexual fantasies over a two year period. He admitted rape, attempted rape and sexual assault.
He was given a three-year youth rehabilitation order.
The court heard how the boy, who had been neglected by his mother for seven years and had been physically abused by his mother's partner, had been allowed to spend hours viewing extreme pornography from the age of nine.
The boy, who cannot be identified, may also have witnessed his mother and partner engaged in sexual activity, the court heard.
He developed an addiction to pornography which culminated in the abuse of the girl.
The court heard that although the boy had initially denied the offences, he later made extensive admissions about his behaviour.
Judge Niclas Parry described the case as extremely worrying and sad and said the neglect by the boy's mother and the physical abuse by her partner had been highly relevant.
"You were brought up in a home that was clearly without sexual boundaries," Judge Parry said.
"In fact what you were doing was using her (the victim) to play out fantasies that you had been watching on the internet, images of extreme pornography," he said.
The judge said it could take years for the boy's victim to understand what happened to her was not normal.
He ordered the boy to serve a three-year youth rehabilitation order with supervision which included a residency order to remain at the child development centre he lives at.
The boy was also ordered to register with the police as a sex offender.
Elen Owen, defending, told the court the boy had had an appalling early childhood and had been subjected to physical and emotional abuse.
Reports on him suggested that there had been an element of satisfying his emotional needs rather than just sexual gratification, she said.