Abortion is set to be decriminalised in NSW on Thursday after the contentious bill passed the upper house following a marathon debate over amendments to appease conservative MPs.

After more than 40 hours of debate, the upper house supported a final amendment relating to late-term abortion on Wednesday night.

Mulgoa MP Tanya Davies said an "agreement" had been reached over the wording of a critical amendment. Credit:AAP

The abortion debate is the third longest in the history of the Legislative Council.

The amended bill is expected to satisfy rebel Liberal MP Tanya Davies, who said an "agreement" was reached over the issue of late-term abortions.