text: Bailey Gwynne died after being stabbed in the heart at Cults Academy in October.
  His 16-year-old killer - who cannot be named for legal reasons - had denied murder but was convicted of the lesser charge of culpable homicide.
  He was sentenced by Lady Stacey at the High Court in Edinburgh. He will be supervised for two years after release.
  The boy was handed an eight-year sentence - and the supervision - for the killing, and another year for weapons offences.
  He will begin serving his sentence in a young offenders institution because of his age.
  The judge told him: "If you had not carried a knife, the exchange of insults between you and Bailey Gwynne would have led at worst to a fist fight - and certainly not loss of life."
  Lady Stacey said the killer had shown "significant regret" and "understanding of the loss you have caused".
  She said he chose to buy weapons online and take them to school on several occasions which was a "very serious matter".
  The judge added: "Nothing that I can say, nor any sentence that I impose, will do anything to lessen the grief that Bailey Gwynne's family and friends feel.
  "The shock of his death at such a young age was felt in the wider community; nothing I can say or do can alleviate that.
  "I have decided that an extended sentence is the only appropriate disposal, taking into account all of the circumstances including your age.
  "I hope that will lead to you being both punished and helped towards rehabilitation while you are detained in a structured environment.
  "Following your release you will be supervised to maximise the chance of your successful re integration into society."
  Defence counsel Ian Duguid said Bailey Gwynne's killer was an "ordinary, naive teenager" who recognised the gravity of what had happened.
  He said the teenager was "constantly monitored by psychiatric services", had post traumatic stress disorder (PTSD) and was medicated for nightmares and depression.
  The fight began after an argument about a biscuit.
  A jury at the High Court in Aberdeen took an hour and 40 minutes to find him guilty.
  Following the verdict, Bailey's mother said the outcome of trial would not bring her "beloved" son back.
  The youth was also found guilty of two further charges of having a knife and knuckleduster in school.
  Aberdeen City Council said the case had been "devastating" for the families affected and staff and pupils at Cults Academy.
  The findings of an independent review into the circumstances surrounding the death of Bailey Gwynne are expected to be published in September.
  BBC Scotland revealed concerns about the killer were voiced nine years ago when, as a primary pupil, he threw rocks at another child.
  The incident resulted in the victim being treated for concussion.
target: A teenager who stabbed a 16-year-old to death in an Aberdeen school has been jailed for nine years.