The bill which will see abortion removed from the Crimes Act and the legal test for the procedure scrapped has passed its third reading.
The conscience vote debate about the polarising Abortion Legislation Bill passed with 68 in favour and 51 votes opposing.
The vote was met with applause and a few cheers.
The Abortion Legislation Bill now goes to the Governor General for Royal Assent and will then be law.
The Abortion Legislation Bill removes abortion from the Crimes Act and drops any legal test for having the procedure earlier than 20 weeks, leaving the decision up to the woman and her doctor.
The current legal test is for two doctors to approve an abortion only if there was "serious danger" to the woman's physical or mental health.
And for an abortion to take place after 20 weeks, it can only be approved if deemed necessary to save the woman's life or prevent serious injury.
The 68 votes to 51 votes against was the narrowest margin the bill passed any of its readings, with 81 to 39 margin after its second reading and the 94 to 23 margin at the first reading last year.
Already today an amendment to put abortion law reforms to a public referendum was been voted down and an attempt to recommit "safe zones" into the bill failed after they were axed in a voting mix-up last week.
Before the bill was passed this evening it was debated in the House.
Ahead of its third reading, Justice Minister Andrew Little introduced the bill and said if passed it would be the most significant changes to New Zealand's abortion framework in 44 years.
The main point of the bill was to take abortion out of the Crimes Act and make it a health issue, Little said.
He said the issue was "tempered with very deeply held views with great passions" and that the public and members on all sides of the House, some he considered friends, had very entrenched views.
Little said he respected everyone's views and was grateful the "debate was largely conducted in a respectful and I think a very thoughtful manner".
"I think we have to respect the fact that when women are in a position to have to make that decision at that point in the pregnancy, it is a very distressing time indeed.
Little said the bill moved New Zealand's laws into the 21st century to reflect modern views.
It also ensured a woman didn't have to lie about her mental health state in order to have a procedure.
"What we need to make sure is that the support services are there for them, the treatment services, the best professional medical advice they can get, and that is an obligation I think we owe in this day and age."