BERLIN — A German teenager was convicted of murder Thursday for killing a 14-year-old girl in a case that was seized upon by far-right groups, who falsely claimed that the perpetrator was a migrant.

A Berlin regional court sentenced the 15-year-old defendant, whose name was withheld due to German privacy rules, to nine years in prison for fatally stabbing his schoolmate Keira G. at least 20 times in her home in Berlin in March.

The judges concluded the boy's motive was a desire to kill, news agency dpa reported. The trial was closed to the public because of the defendant's young age.

The girl's mother, who had found her dying daughter in the apartment when she returned from work, was present for the verdict.

Dpa reported that the German-born boy had planned the murder in advance and had told the girl, whom he knew from school, that they would meet for homework.

A court official could not immediately be reached for further comment.

Keira G's killing sparked a flurry of social media posts by far-right groups and individuals alleging the crime had been committed by a migrant, and accusing the authorities of hiding the culprit's true identity.