BERLIN (Reuters) - A German court on Thursday sentenced an Afghan migrant to life in prison for raping and murdering a university student, as the country wrestles with security and integration concerns after taking in over a million migrants since 2015.

In December 2016 police detained the young Afghan man, who had arrived in the country at the height of the refugee crisis a year earlier. A test determined that his DNA matched that found near the site where a 19-year-old German female student had died in the southwestern city of Freiburg two months earlier.

A police autopsy found she had been a victim of sexual crime and violence before she drowned in a river.

In January, a government-sponsored study found that violent crime rose by about 10 percent in 2015 and 2016, and more than 90 percent of the rise was attributed to young male refugees, adding fuel to a political debate over the handling of the migrant crisis.

Fears about security and the assimilation of migrants helped pave the way for the right-wing Alternative for Germany (AfD) to win third place in an election last September, and it has now become the official opposition in parliament.

The Afghan man, identified only as Hussein K. under reporting rules, was sentenced to life in prison and preventative detention thereafter, the court in Freiburg said, meaning he will never walk free in public.

He had been convicted of attempted murder in Greece in 2013 and sentenced to 10 years in jail, but he was released in 2015 on parole and fled to Germany.

The German court sentenced Hussein, who was allegedly 17 years-old when he committed the crime, as an adult, not as a minor, after it concluded with experts that he was an adult at the time of the offense.

“After an overall assessment of the personality of the defendant and the environmental conditions, the Chamber has come to the conclusion that his mental and moral development is no longer equal to a young person,” the court said.

In January, a fatal stabbing of a 15-year-old German girl by a suspect identified by police as her former boyfriend, an Afghan migrant, fueled a debate about verifying the ages of unaccompanied minors seeking asylum in Germany.