A 12-year-old boy raped and repeatedly sexually assaulted a nine-year-old girl after he watched porn online and wanted to feel "grown up", a court has heard.

But the schoolboy, from the Isle of Skye in Scotland, was spared jail by Edinburgh High Court's presiding judge, amid warnings the case was the "tip of the iceberg".

The boy's lawyer, Sean Templeton, said there could be many more similar cases in the future because pornography is giving children a "skewed view" of sex.

The court was told how the boy was allowed "unfettered" access to adult websites, which led him to emulate what he had seen online.

He abused the girl, who was his next door neighbour, several times during 1 December 2010 and 31 January 2011 and explained he did so because of "temptation". On one occasion, he sexually assaulted her in his bedroom while a 12-year-old friend watched.

The offences only came to light when the girl complained she had a sore stomach and told her mother she was worried she had "a baby in my tummy".

When questioned by her mother, the girl became hysterical before revealing what the boy had done.

The boy, who pleaded guilty to one charge of rape and two of sexual assault, appeared in the dock shaking.

Judge Lady Smith spared him from jail and told him he was being handed an opportunity to "make something of yourself".

He was given a four year supervision order which means he will be monitored closely by social workers until he is 18. He will also receive relationship and sexual development advice.

"You should not and must not regard pornography as any guide at all as to how to behave sexually," the judge told the boy. "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.”