Boy, 12, spared custodial sentence for rape of a nine-year-old girl
The High Court in Edinburgh was told the boy, who is now 14, was 'emulating' the actions he had seen after having 'unfettered' online access.
Judge Lady Smith said the case would be referred to the Children's Panel and the boy kept under close supervision until the age of 18.
The boy's defence counsel, Sean Templeton, said: "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
"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 added: "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."
Mr Templeton said that the boy had identified the websites he visited to police. "The behaviour witnessed was reminiscent of the acts carried out by him," he said.
Lady Smith told the teenager that having looked at detailed reports prepared in his case, she could consider a non-custodial sentence.
'She told the boy he must 'behave' and that he was being given an opportunity to 'make something' of himself, to put his mistakes behind him and accept the wrongdoing and to think carefully of what it was like for the girl and 'what she is living with because of that wrongdoing'.
The judge told him: "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."
The judge pointed out that he had pleaded guilty to statutory offences under the Sexual Offences (Scotland) Act 2009.
The boy, who cannot be identified for legal reasons, had earlier admitted statutory offences of rape and sexual assault committed between 1 December 2010 and 31 January 2011 at a Scottish island community.
Advocate depute, Jane Farquharson said the offences came to light after the girl complained of having a sore stomach.
She eventually asked her mother if her problem could be because she was about to have a baby. Her mother asked her if something had happened to her and she became hysterical before revealing what the boy had done.
The victim's mother had said in a statement that she would like the boy to get help.
Mr Templeton argued that there were benefits in sending the case to the children's panel as it would allow supervision to continue until he was 18.
He said: "The hope obviously is the behaviour can be addressed in order that he can go on to have a normal adult life with normal relationships with other adults."
The case was heard in a closed courtroom with only relatives of the accused, care workers and members of the press in the public benches.
More on Parentdish: My teen watches porn
My son has been looking at porn. What can I do?