“There is no country in the world where the circumcision of boys for religious reasons is considered a criminal act,” Ms. Leutheusser-Schnarrenberger said. “With this legislation, the German government makes clear that Jewish and Muslim life is clearly welcome in Germany.”

The Cologne court’s ruling provoked outrage in Israel, Turkey, the United States and elsewhere. It proved an embarrassment to Chancellor Angela Merkel’s government, painfully aware that postwar Germany can ill afford to be seen as supporting such a dangerous message of intolerance. Most of Germany’s four million Muslims are from Turkey or of Turkish descent.

“I find it particularly sad that in the necessary weighing of the various legal elements in the circumcision debate, every level of inhibition appears to have been lost to finally tell Jews and Muslims what is good for them,” Ms. Merkel said at a gathering of Jewish leaders in November, after months of fractious debate on the issue. The legislation must also be approved by the upper house of Parliament, the Bundesrat, which is expected to pass it.

Unlike common practice in the United States, infant boys in Germany and most other European countries are not routinely circumcised for health reasons. Consequently, the practice is unfamiliar to the general public, even to most lawmakers voting on Wednesday, as Aydan Ozoguz pointed out.

“It is a particular challenge that among this body, only very few members belong to the Jewish or Muslim faiths,” said Ms. Ozoguz, a lawmaker from the opposition Social Democratic Party, who was born in Germany to Turkish parents. She pointed out that a ban on the practice in the early years of a boy’s life would “create an opportunity for Jews and Muslims to be pursued by prosecutors and as a result, sweepingly criminalized.”