Lawmakers voted 77 to 44 Wednesday night in favour of the gay-marriage bill.
People watching from the public gallery immediately broke into song after the result was announced, singing a New Zealand anthem in the indigenous Maori language.
Leaders of most political parties encouraged lawmakers to vote as their consciences dictated rather than along party lines.
Same-sex marriage is currently recognized in the Netherlands, Belgium, Spain, Canada, South Africa, Norway, Sweden, Portugal, Iceland, Argentina and Denmark. Lawmakers in Uruguay approved a law last week that President Jose Mujica is expected to sign.