The German government pleaded for calm on Monday after the arrest of a teenage Afghan asylum seeker for the alleged rape and murder of a German student triggered fresh criticism of the country's liberal refugee policy.

The anti-migrant AfD party blamed the crime on the "uncontrolled" influx of foreigners, while the head of a police union warned of the "dangers that always go along with massive immigration".

But Chancellor Angela Merkel warned against "rejecting an entire group".

"If it turns out that it was an Afghan refugee, well then it's absolutely condemnable, as any other murder would be," she told public broadcaster ARD.

Likewise, Vice Chancellor Sigmar Gabriel said the murder of the 19-year-old medical student should not be used to whip up hatred against all refugees.

"Such horrible murders already happened before the first Afghan or Syrian refugee arrived here," Gabriel told the Bild newspaper. "We will not allow incitement after such violent crimes, no matter who commits them."

The 17-year-old suspect, who arrived in Germany in 2015 as an unaccompanied minor, was arrested in the southwestern town of Freiburg on Friday after his DNA was found at the crime scene and he was identified on CCTV.

The victim was found dead on a river bank on October 16. An autopsy found that she had drowned.

News of the arrest triggered strong reaction on social media with some people saying an ironic "thank you" to Merkel, whose open-door asylum policy brought a record number of migrants and refugees into Germany last year.

- 'Warnings written off' -

The chairman of the DPoIG police union, Rainer Wendt, said the killing could have been prevented.

"We wouldn't have this victim, and so many others, if our country had been better prepared for the dangers that always go along with massive immigration," he told Bild.

AfD co-chief Joerg Meuthen, whose party has made gains on rising discontent over the flood of refugees, said: "We are shocked by this crime and at the same time we see that our warnings about the uncontrolled arrival of hundreds of thousands of young men from Islamic-patriarchal cultures are written off as populist."

Story continues

Germany received 890,000 asylum requests in 2015, although that rate slowed to 213,000 from January to September 2016 following a deal with Turkey and a series of border closures on the Balkan route.

Public anger about the refugee arrivals has been stoked by some high-profile crimes involving migrants.

During the last New Year's Eve celebrations, hundreds of women reported sexual assaults in Cologne and other German cities, with the attacks blamed largely on Arab and North African men.