The sentencing in the western German town of Landau came at a time when anti-migrant protests have erupted in the eastern city of Chemnitz over the fatal stabbing of a man, allegedly by a Syrian and an Iraqi.
The judges sentenced Abdul D., who says he is from Afghanistan, for the murder and assault of the teenager called Mia, following a juvenile justice case, the court said on Monday.
The prosecution had previously demanded a prison sentence of 10 years, while the defence hoped for seven years and six months for manslaughter, reports Focus Online. Prosecutors believe that he acted out of jealousy after she broke up with him.
The incident happened on December 27th, 2017 in the middle of a drugstore and caused nationwide horror.
Right-wing populist groups took the case as an opportunity to repeatedly protest in Kandel against the asylum policy of the federal government.
The case also fuelled the discussion about the age determination of young refugees.
After his arrival in Germany, Abdul D. was admitted and cared for as an unaccompanied minor refugee. He said he was 15-years-old at the time of the crime; however, doubts have been raised about his age.
An expert had estimated his age as between 17 and a half and 20 years old. Nevertheless, the court hearing took place behind closed doors and under juvenile penal rules.
Abdul D. arrived in Germany in April 2016 and his request for asylum was rejected on February 2017, although he was not immediately deported.
The case is one in a string of high profile crimes allegedly committed by asylum seekers that has stoked popular anger against the new arrivals and put pressure on Chancellor Angela Merkel over her liberal refugee policy.
Far-right party Alternative for Germany (AfD) has been mobilizing regular demonstrations over the killing in the small town with a population of just 9,000, as it sought to bolster its anti-migrant campaign.
At the peak of the protests, thousands marched in Kandel. But they appear to have since lost momentum.
On Saturday, a demonstration in the town attracted 350 people, local police said.
Residents of the small town frustrated by the far-right rallies also lined the demonstration route, carrying banners like "Stop hate and incitement" or "Kandel is colourful, not brown" - in reference to the Nazi's khaki uniforms, according to DPA.
Rhineland-Palatinate state premier Malu Dreyer accused the far-right of exploiting the teenager's death for political gains, saying it was "intolerable".
"It is the hope of all of us that once the trial is over, peace will return to Kandel," she said.