Legislation banning conversion therapy has passed its third and final reading at Parliament with the support of almost all MPs.
The Conversion Practices Prohibition Legislation Bill was only opposed by eight National MPs.
Conversion therapy involves attempts to change a person's sexual orientation or gender despite there being no scientific basis for it - and evidence it does harm.
Deputy Prime Minister Grant Roberston told the House during the third reading the legislation rights a wrong.
"A hurtful, insidious, destructive wrong. But it also sends a message - a message of love support and affirmation to all in the rainbow communities."
He shared his experience of growing up gay in a religious household.
"There were plenty of negative messages for me to hear as I grappled with my sexuality and the challenge of feeling very different from those around me. When I finally gathered the courage to come out to my parents, I was met with love. Whatever fears that they held for me, and I know that they did, they were full of acceptance, but not everybody is or was so lucky."
The legislation bans the practice of trying to change or suppress a person's sexual orientation, gender identity, or gender expression.
Anyone who performs conversion therapy on someone under 18 years old could be jailed for up to three years and up to five years if they've caused serious harm, irrespective of age.
Labour MP Kieran McAnulty said you can't change what isn't broken.
"There is nothing wrong with being gay. There is nothing wrong with being trans. What is there to change? What is there to convert? This whole concept that there is this process that could change someone from being gay to being straight is a falsehood."
Under former leader Judith Collins, National voted against the bill at its first reading, straining the party's liberal and conservative fractions.
National, now led by Christopher Luxon, U-turned at second reading, with its caucus agreeing to vote with their conscience.
25 National MPs supported the legislation this evening and 8 opposed it - one more than the second reading.
Simon Bridges, Simeon Brown, Melissa Lee, Todd McClay, Simon O'Connor, Chris Penk, Shane Reti and Michael Woodhouse opposed the bill.
Louise Upston opposed the bill at second reading and supported it at third, while Penk and McLay changed their position between second and third readings.
None of the National MPs who oppose the legislation spoke during the third reading.
National's Paul Goldsmith said his concerns about what is captured in the definition of a conversion practice have been alleviated.
"My hope now is that this bill will be one that does provide future generations of young people from all sorts of backgrounds to have that level of confidence that they won't be exposed to some of the terrible practices that some of the earlier members of the community have faced."
ACT Deputy Leader Brooke Van Velden shared her party's support for the ban.
"I want to live in a country where we accept all people, that we have a common humanity, and all people are respected to live the lives that they want to and they're respected for being themselves."
The new criminal offences will come into force immediately following Royal Assent.