New Zealand has passed a landmark bill that treats abortion as a health issue rather than a crime, a major reform in laws that have been unchanged for more than four decades.

The reform passed through parliament late on Wednesday by avote of 68 to 51.

The legislation modernises abortion laws in place since 1977 and proposes that a woman should have access to abortion until 20 weeks of pregnancy, with advice from her doctor.

After 20 weeks, a pregnant woman would require a test and two doctors will have to agree an abortion is the right decision. These conditions for post-20 week pregnancy were tougher than the government's original proposal.

Under the old law abortion was an offence in New Zealand, and a woman could only legally get an abortion if two doctors certified that continuing the pregnancy would result in danger to her mental or physical health.

"For over forty years abortion has been the only medical procedure considered a crime in New Zealand. But from now abortions will be rightly treated as a health issue," Minister of Justice Andrew Little said in a statement after the law was passed.

The passing of the bill is seen as a win for Prime Minister Jacinda Ardern's centre-left coalition party, ahead of a general election in September.

Decriminalising abortion was one of Ardern's campaign promises when she was elected in 2017 but plans to change the laws were delayed as lawmakers argued over the bill.