The teenage killer of schoolboy Bailey Gwynne has been detained for nine years.

The 16-year-old died after being stabbed through the heart by a fellow pupil at Cults Academy in Aberdeen on October 28.

His killer, also 16, was charged with murder but found guilty of the lesser charge of culpable homicide at the High Court in Aberdeen last month.

Judge Lady Stacey sentenced the teenager, who cannot be named for legal reasons, at the High Court in Edinburgh on Friday.

He will serve nine years in detention at a young offenders institution with two years supervision after his release.

Lady Stacey told the court that had he not been carrying a knife, the incident at Cults Academy would have been a "fist fight at worst".

She described him as a "risk to others" and said it was "obvious that buying the knife and taking it to school led to terrible events".

But she told the boy: "You have shown significant regret and understanding of the loss you have caused."

Defence advocate Iain Duguid QC told Lady Stacey that social workers who interviewed his client had concluded he was "immature and naive". Mr Duguid said that the boy regretted attacking Bailey and that he accepted a custodial sentence was inevitable.

He added: "This word 'tragedy' is written all over this case. He is immature and naive. He is 16-years-old and he can recognise that he has ended somebody's life.

"He feels profoundly sorry for his actions. He recognises that there is nothing that he can do to reverse the events of that day.

"It has profoundly affected him. He is constantly monitored by psychiatric services. He is suffering from Post Traumatic Stress Disorder and he is receiving medication for nightmares and depression.

"It is obvious that he will continue to be monitored within the prison environment.

"There's a very limited future for him - following his release from prison, he will return to the area where this crime was committed as his family and support network are there.

"He himself recognises that there won't be too many employers who would be willing to give somebody who has taken a person's life a job."

Lady Stacey jailed him for one year each on weapons possession charges. However, these terms will run concurrently to each other and consecutively to the culpable homicide charge, for which he will be detained for eight years.

The folding knife used in the killing was illegally bought from online retailer Amazon. The 16-year-old told officers he bought the knife online "because they don't check if you're over 18" and said he carried knives and knuckledusters to "be cool".

Bailey's family made no comment as they left court.