After years of anguished discussion on the need for tougher treatment of rape by the German criminal justice system, the new legislation finally came together following a rash of sexual assaults in crowds on New Year's Eve in the western city of Cologne.
Deputies gave a standing ovation as the law passed the Bundestag lower house with an overwhelming majority, following an emotional debate.
Dubbed the "no means no" law, it explicitly covers cases in which a victim withheld consent but did not physically fight back. It brings what critics call woefully lax legislation into line with that of many other developed countries.
Justice Minister Heiko Maas acknowledged that under German law there were "unacceptable gaps in protection" against sexual coercion and assault.
Chancellor Angela Merkel's cabinet signed off on the measures in March after the attacks in Cologne, where more than 1,000 women reported sexual assaults and robberies on New Year's Eve, which were blamed largely on Arab and North African men.
The draft law was toughened again by the ruling left-right coalition last month.
A first attempt at prosecution in May was thrown out by a court when the alleged victim said she could not identify the defendant as her attacker.
A second trial began today just as the Bundestag began its debate, with an Iraqi and an Algerian in the dock accused of groping one woman's buttocks and crotch and licking the face of another. Both are also accused of attempted robbery.
The new law is intended to cover "the actual situations in which most attacks occur", Maas said.
These include cases in which the victim is taken by surprise, intimidated or threatened with other violence, for example in an abusive relationship, or is unconscious.
