The German parliament has passed legislation making it easier to deport failed asylum seekers and monitor those deemed dangerous in a move that has been slammed by opposition parties and rights groups as an assault on the rights of refugees.

In legislation passed by the Bundestag late on Thursday, German authorities will be able to detain refugees due for deportation for 10 days rather than four, and monitor by ankle bracelet those deemed potentially dangerous.

The legislation also restricts freedom of movement for all failed asylum seekers. It grants the federal refugee agency BAMF and other government bodies more leeway to use and share data retrieved from migrants' mobile phones.

OPINION: Angela Merkel is not the great progressive messiah

Refugee organisation Pro Asyl criticised the measures, saying that they robbed refugees of their right to privacy.

"The agreed package of measures for tougher deportation policies is a programme that will deprive asylum-seekers of hope for protection in Germany and is aimed at discouraging them," the organisation said in a statement.

Defending the move, Interior Minister Thomas de Maiziere referred to the new measures as "a conclusion of efforts to tighten asylum laws in this legislative period".

The measures were decided partly as a response to a truck attack in Berlin in December in which 12 people were killed. Although attacker Anis Amri's asylum request had failed and he was under surveillance by police, the authorities failed to deport him.

Amri, a 24-year-old, had been living in Germany as an asylum seeker. He was killed in Italy after he pulled a gun and shot an Italian officer in the shoulder during a routine police check.

Hundreds of German investigators are investigating how Amri managed to flee Germany after the attack and whether he may have had accomplices or a support network that helped him escape.