Chancellor Angela Merkel's grand coalition government used its large majority in the lower house Bundestag to easily pass the law, which Justice Minister Heiko Maas described as "a declaration of war on cheaters," Deutsche Welle wrote.
Under the legislation, athletes found guilty of doping could face fines or prison terms of up to three years. Those involved in supplying athletes with performance-enhancing substances could face jail terms of up to 10 years.
Maas said the legislation, which was jointly drafted by the justice, interior and health ministries, would make German sports "cleaner, safer and more honest."
"This is a historic day in sports politics. Doping will become a case for the prosecutor's office," Maas said in a speech to the Bundestag. "In view of the current situation in Russia, the problem doesn't seem to be getting smaller, but seems to be growing," he said, referring to a damning report released by an independent commission appointed by the World Anti-Doping Agency (WADA) earlier this week.
Interior Minister Thomas de Maiziere, whose ministry is responsible for sports, said the law was meant "to deter and to help uncover criminal doping structures."
The Germany Olympic Sports Federation (DOSB) said it supported the legislation in principle, but also expressed concerns that it could undermine the efforts of sporting authorities to combat the problem. Speaking to SWR public radio, Maas rejected this, arguing that sports authorities alone had proven not to be a strong enough deterrent.
The bill still has to be passed by the Bundesrat upper house before it can come into force, however this is regarded as a formality.
Meanwhile, elected members of the International Association of Atheltics Federations (IAAF) were to hold a conference call later on Friday to discuss whether to suspend the Russian federation over allegations of state-sponsored doping of its athletes. The allegations came from the report released by the WADA independent commission on Monday.