After weeks of heated debate, the Reproductive Health Care Reform Bill has passed the NSW Parliament.
Abortion will be removed from NSW's 119-year-old Crimes Act after the controversial bill passed the state's lower house to applause.
MPs voted in favour of the amended legislation on Thursday morning, a day after it passed the upper house after nearly 40 hours of discussion. The bill was passed with no division.
Independent MP Alex Greenwich, who first introduced the proposed legislation to Parliament last month, presented the amended bill to the lower house for the final time.
"Thank you to all members for the role you have played in this historic reform ... we can feel proud that part of our legacy will be the decriminalisation of abortion in NSW," the Member for Sydney said.
NSW Premier Gladys Berejiklian was not in the chamber for the final vote.
"I had full confidence that the Parliament would resolve the matter in a great way," she told reporters on Thursday.
The Reproductive Health Care Reform Bill 2019, which was co-sponsored by 15 MPs across the political spectrum, removes abortion from the NSW Crimes Act and allows for abortions up to 22 weeks to be performed by a registered doctor.
For terminations after that point, the consent of two doctors would be needed.
Previously there were no options in NSW for people seeking an abortion after 20 weeks.
The legislation was passed with a number of amendments, including that doctors performing abortions after 22 weeks be able to seek advice from a multi-disciplinary team or hospital advisory committee and that doctors must provide care to babies born alive after an attempted termination.
One of the most controversial proposed amendments - labelled "racist" by critics - sought to ban abortions for the purpose of sex selection but was voted down in the upper house.
The Legislative Council also voted to change the name of the bill to the Abortion Law Reform Bill 2019.
More than 100 amendments in total were discussed for nearly 40 hours, making it the third-longest debate in the NSW upper house.
The debate over the bill has been fraught, with a number of state and federal politicians launching fiery attacks against the proposed legislation and challenging Ms Berejiklian's leadership.
One of the most outspoken opponents of the bill, Liberal MP Tanya Davies, said on Thursday morning that she would be supporting the amendments.
"Many of us within the Parliament, and also outside in our communities, had concerns with the original bill ... concessions, amendments, changes to the original bill were moved through both houses of Parliament and that is a good thing," she said.
"I honestly believe the amendments ... create more safeguards for women."
Ms Davies had previously planned to launch a leadership spill against Ms Berejiklian over her handling of the issue but backed down last week.
Federal Nations MP Barnaby Joyce and former prime minister Tony Abbott were also vocal about their opposition to the bill, speaking at an anti-abortion rally earlier this month.
Mr Abbott labelled abortion "infanticide on-demand", while the former Nationals leader described the debate over the bill as "the slavery debate of our time".
In a statement released on Thursday afternoon, the Catholic Archbishop of Sydney said it was a "very dark day" for NSW and the new law was "a defeat for humanity".
"The Abortion Law Reform Act 2019 may be the worst law passed in New South Wales in modern times because it represents such a dramatic abdication of responsibility to protect the most vulnerable members of our community," Archbishop Anthony Fisher said.
Amnesty International praised the decision and congratulated MPs for voting with "common sense".
"It has been a long fight by many organisations and individuals and brings NSW in line with the rest of Australia in acknowledging that women’s rights include the right to control your own body and your reproductive health," Amnesty International Australia National Director Claire Mallinson said in a statement.
Greens MP Jenny Leong, a long-time campaigner for abortion rights, said passing the bill would allow people to make "personal and private decisions" for themselves.
"I cannot believe we are here, but I also cannot believe it took so long," she said, prior to the vote. "We are on the cusp of something huge".
"Today we have moved closer to the ideal of realising gender equality for all in this state," she added.
While abortion was previously outlawed in NSW, a loophole established by case law meant a doctor could perform an abortion only if they believed continuing the pregnancy would be harmful to the woman's health.