Germany may soon start limiting the number of refugees it accepts as it struggles with the growing migration crisis.
President Joachim Gauck said it is likely controls on migration will be introduced in Germany this year.
"Because we want to provide as much protection [for refugees in Germany] as we can, at some point, even though it's tragic... we will have to limit migration," he said at the World Economic Forum in Davos.
Germany has taken in more refugees than any other European country, welcoming around one million last year.
Gauck said Germany must continue to help refugees despite the drawbacks. "People who need our protection are allowed to cost us something," he said.
The country was applauded for its decision to welcome many of the refugees who have made the journey to Europe in search of safety, work and a better life.
But the mood has changed following a recent wave of alleged sexual attacks and robberies in the country. German police have been accused of covering up the attacks, adding fuel to the heated migration debate.
Opinion: Big business must "hack" refugee crisis
Gauck said limits on the number of refugees might be "morally necessary to protect the state's ability to exist." He also called on other European countries to take in their share of refugees.
He said many Germans are increasingly worried about safety and the ability of police to ensure the law is respected, and that controls on migration will give them confidence that Germany can cope with the crisis.
Related: Can Europe afford border controls?
"Following recent events in several German cities for instance, it was feared that fundamental achievements of our civilization such as tolerance, respect and the equality of women could be damaged," Gauck said.
The migration crisis was presenting the EU with its "biggest ever test," he said, warning that unless its external borders were reinforced, the block's prized freedom of movement would be put at risk.