The third and final reading of the End of Life Choice Bill has been passed in Parliament by 69 votes to 51.
The member's bill, in the name of ACT leader David Seymour, allows terminally ill adults to request a medically-assisted death.
It cleared its second reading 70 votes to 50 in June and easily passed tonight after impassioned debate.
However, it will still take a majority referendum result at next year's General Election before the legislation can be enacted.
There were passionate speeches both for and against the bill and holding a referendum.
Of those opposed, National MP Chris Penk warned against the bill going to a public poll.
"Is it responsible for us as lawmakers to hand a loaded gun to fellow New Zealanders and say 'don't worry I have applied the safety catch?', knowing very well that for many New Zealanders the only words of the bill they will ever read before such a referendum will be the title of the bill," he said.
Mr Penk told the house polling showed 70 percent of the public, believed the bill concerns itself with orders not to resuscitate, which are already legal.
He added 74 percent thought to switch off life support is within the remit of the bill.
But New Zealand First MP Tracey Martin defended the bill going to a referendum.
"Because it is such an unusual topic of such a momentous decision for New Zealand we agree that it is right and proper our consciences, which I hear the words of others who talk about the tyranny of the majority, surely this would be the dictatorship of the minority."
Ms Martin told the house the New Zealand public voted MPs to Parliament on party manifestos rather than their individual consciences.
On the front lawn of Parliament this afternoon a protest group of a few hundred people brandished signs opposing the legislation - "caring not killing", and referring to the Bill's "weak safeguards".
Labour list MP Jamie Strange told the crowd MPs from across the House would support them in their opposition.
National's Alfred Ngaro, a list MP, told them the Bill was going ahead despite the direct opposition of thousands of New Zealanders, including some in the medical community - "still, here we are today".
He encouraged them to "keep the faith because there are those who believe that this is wrong".
National MP Dr Shane Reti had asked the House, as a medical practitioner and a Māori, to vote against the end of Life Choice Bill.
Shane Reti had said the bill would change the very fabric of the doctor-patient relationship.
Before the vote, Mr Seymour had said he was "quietly confident" the Bill would pass, but would continue working for votes up to the last minute.
"We've had the arguments - I don't think anyone will ever be able to say that Parliament didn't properly scrutinise this bill," he said.
"It's been nearly two years since the parliamentary process started. And over that time we've kicked around every conceivable argument for and against the bill."