Germany's parliament has passed a law banning so-called "gay conversion therapy" for young people nationwide.
The legislation is intended to stop groups offering the service - which claims to be able to change a person's sexual orientation - to under-18s.
Those breaking the new law can face up to a year in prison, or a €30,000 ($32,535; £26,268) fine.
Research suggests the controversial practice can lead to depression and increase the risk of suicide.
Under the law, passed on Thursday evening, minors will not be allowed to take part in medical interventions aimed at changing or suppressing their sexual orientation or gender identity.
Parents and legal guardians can also be punished for making their children take part through deception, coercion or threats.
Conversion therapy practices can include hypnosis and electric shocks. But experts say the word 'therapy' is misleading because there is no scientific basis for it.
German Health Minister Jens Spahn said a robust law was needed to protect it from court challenges, adding that most people who attended treatment were young people forced to do so by others.
"They should feel strengthened when the state, when society, when Parliament makes it clear: we do not want that in this country," said Mr Spahn, who is gay himself.
Mr Spahn, a member of Chancellor Angela Merkel's Christian Democrats (CDU) party, first announced plans to ban the practice last June, and a bill was drafted in November.
However critics argue the law does not go far enough. Germany's opposition Green Party has called for the age limit to be raised to 26 - the Left Party wants it to be 27.
Around 1,000 people are subjected to conversion therapy in Germany every year, according to the Magnus Hirschfeld Foundation, a Berlin-based human rights organisation.
The practice is outlawed in Switzerland and areas of Australia, Canada and the US.