MPs voted on the law as hundreds of people demonstrated outside the Bundestag (German parliament) building against the plans, which have been hugely unpopular with digital rights activists.
Informationelle Selbstbestimmung nicht gefunden. https://t.co/sEDihwyd4x— Torsten Beeck (@TorstenBeeck) October 16, 2015
"Data self-determination not found," tweeted Spiegel Online social media journalist Torsten Beeck, referencing the commonly seen "Error 404" page shown by browsers when they can't find a webpage.
Vice-Chancellor Sigmar Gabriel writing messages on his smartphone during the Bundestag vote on data retention. Photo: DPA
The law means that all telecommunications metadata - including computer addresses and phone numbers - will be saved for ten weeks, in a measure which the government claims will help fight terrorism and serious organized crime.
Data about the location of participants in mobile phone conversations will be saved for four weeks, while no information will be kept about email exchanges.
The government says that the contents of people's communications will not be saved.
But the Süddeutsche Zeitung reported that – due to a technical issue – the contents of SMSs will also be saved for ten weeks.
While the law would not give government or phone companies the right to view the contents of telecommunications, SZ argues that the potential for abuse of the system has been seriously increased.
Court challenge planned
The controversial law is also set to face a legal challenge in Germany's highest court after Wolfgang Kubicki, deputy leader of the liberal Free Democratic Party (FDP) told Die Welt that he intends to bring it before constitutional court judges in Karlsruhe.
Kubicki explained that a European High Court ruling protected the privacy of people who carry professional secrets.
"Because the government is ignoring this [ruling], litigation is necessary,“ said Kubicki.
Within the coalition government this law has proved to be one of the most divisive.
Justice Minister Heiko Maas of the left wing Social Democratic Patry (SPD) resisted its introduction for months. But in the spring he struck a deal with Interior Minister Thomas de Maizière over the time frame of data storage.
There is currently no law in Germany which covers government data collection, after a 2010 attempt at legislation was overturned by the constitutional court.