A bill that will allow same-sex couples to adopt children in NSW has been passed by the lower house of parliament by only two votes.
Forty-six MPs voted for the historic bill while 44 voted against it on Thursday, following two days of debate.
The controversial bill, introduced by independent Sydney MP Clover Moore, allows same-sex couples to adopt a child together.
Gay couples can already adopt in the ACT and Western Australia.
Voting on the issue in NSW was always going to be close and the result initially looked unclear as a similar number of MPs filled each side of the parliamentary floor.
News that makes sense
Your trusted source for staying up-to-date with the world around you. Get free daily news updates and analysis, straight to your inbox.
At the last minute, the doors were unlocked for dissenting MP and leader of the Nationals Andrew Stoner, late because of a problem with the lift.
As the result was called, a whoop and brief applause rang out and Ms Moore was hugged and congratulated by her fellow MPs.
Reintroducing the bill on Wednesday, Ms Moore included an amendment that gives church adoption agencies the right to refuse services to same-sex couples without breaching anti-discrimination laws.
She did this "against her strong belief" in the hope it would encourage more MPs to support the bill.
Premier Kristina Keneally, Opposition Leader Barry O'Farrell and Mr Stoner had allowed the MPs a conscience vote on the contentious issue.
Ms Keneally and Mr O'Farrell both supported the bill, while Mr Stoner did not back it.
The issue split the Liberal Party and the Nationals with senior members of the coalition, including Greg Smith, voting against it.
Labor MPs were also divided with Noreen Hay and Virginia Judge among those voting opposed.
Those supporting the bill argued it would give recognition to the estimated 1300 children in NSW already being cared for by same-sex couples through foster care or the care of a partner's child.
The bill would not affect inter-country adoptions because none of the countries Australia has agreements with allows same-sex adoptions.
Nor is it likely to affect local adoptions, of which there were just 20 last year, they said.
Instead, the bill would most often apply to known adoptions, where a couple adopt a foster child, or a parent adopts the child of his or her partner.
Speaking to the lower house on Wednesday night, Ms Keneally said she had considered the Gospel, her observations of same-sex parents and her own experiences of parental love both as a child and a mother.
"In considering all of that, I must, in my conscience, support this legislation," she told parliament.
"In forming my position on this bill, I have considered my experiences as a mother, my responsibilities as a parliamentarian, and my conscience as a Christian and member of the Catholic faith."
Speaking on Thursday morning, Mr O'Farrell said he supported the bill, but added the issue was not a matter of gay rights, but of removing discrimination in the Adoption Act.
"I support this measure today ... for the sake of children, but also because I don't believe our society should exclude because of gender, sexuality, faith, background or some other factor, people who have a contribution they can make," he said.
Mr Stoner was the dissenting voice among the leaders, saying children needed to be raised in an environment where there was a father and a mother.
"As a father of six children I know that my children have benefited from having parents of both genders, male and female," he told parliament on Wednesday night.
Children's agencies Barnardos, Benevolent Society charity and UnitingCare Burnside, one of the largest child and welfare agencies in NSW, were all in favour of the bill, which they said would boost foster carer numbers throughout the state.
Many faith-based organisations were against the bill, with 200 people protesting against it at a NSW Council of Churches public meeting in state parliament on Tuesday.
Christian Democratic Party leader the Reverend Fred Nile told the meeting the bill could deter women thinking of adopting out their child and "lead to the tragedy of abortion".
Further amendments to the bill will be put to a vote this afternoon before it is sent to the upper house.

