A 12-year-old schoolboy raped and sexually assaulted a younger girl after copying hardcore pornography he watched on the internet, a court has heard.

A judge at the High Court in Edinbugh warned the case was just the 'tip of the iceberg' and said there may be many similar cases throughout the country.

The High Court in Edinburgh heard the boy, now aged 14, was allowed “unfettered” access to adult websites before forcing a nine-year-old to perform a sex act on him.

Sean Templeton, the boy’s defence counsel, said the case could be “the tip of the iceberg” because pornography is giving a generation of youngsters a “skewed view” of sex.

Judge Lady Smith decided not to detain the teenager but warned him that he should not regard pornography as a “guide” on how to behave sexually.

The appalling details of the case emerged amid growing political debate as to whether the UK Government should force internet providers to adopt an “opt-in” system.

This means parents would have to remove a default block on watching pornography on their home computers, thereby preventing their offspring accessing adult images.

Mr Templeton told the court that his client’s response to police questions about why he conducted the attack was “temptation” and “to feel grown up”.

“This was an emulation of an adult act witnessed by him at this young age. He was afforded unfettered access to the internet and it has become apparent from a very young age, the age of 12, he was accessing hard-core pornography,” he said.

“This is the tip of the iceberg. Many, many cases throughout the country may not be identified, not reported, not coming to anyone's attention.”

He the court pornography was discussed by first-year pupils at secondary school, concluding: “There is a real risk that young people of the current generation of teenagers are growing up with a skewed view of what sex is and sexual activity."

The boy, who cannot be identified for legal reasons, had earlier admitted statutory offences of rape and sexual assault committed between December 1, 2010 and January 31 last year on a Scottish island.

Jane Farquharson, the advocate depute, said the offences came to light after the girl had been complaining of having a sore stomach.

Her mother asked her if something had happened to her and she became hysterical before disclosing the boy’s actions. Police found a 12-year-old friend of the boy who had seen a sex act being carried out.

Mr Templeton said the boy told officers which websites he visited and his lawyers conducted an investigation that found they contained images “reminiscent of the acts carried out by him.”

Sentencing him, Lady Smith referred the case to the children's panel, meaning the boy will be kept under supervision instead of custody.

She said he would receive advice on relationships and sexual development, adding: “You should not and must not regard pornography as any guide at all as to how to behave sexually.

“You should not have engaged in sexual activity of any sort with a nine-year-old girl or indeed any other young girl who, under our law, is not able to consent to it.”