After decades of campaigning NSW has become the last state in Australia to pass laws allowing people with a terminal illness to voluntarily end their own life.
Campaigners say they will now take their fight to the territories.
Thursday's decision means within 18 months people with a fatal diagnosis in NSW will be able to access voluntary assisted dying.
Prime Minister Scott Morrison said if re-elected on Saturday his government would not remove a ban on voluntary assisted dying in the Northern Territory and the ACT.
"There are differences between territories and states and ... we're not proposing any changes," he said on Thursday after the bill passed.
Independent MP for Sydney Alex Greenwich introduced the private member's bill to the lower house last year with a record 28 co-sponsors from across the political spectrum.
He said it was not fair people in the ACT and the Northern Territory were being blocked from reform by a "stubborn person".
"I'm standing here today with members of the Labor Party, the Liberal Party, and we've got strong support within the National Party," Mr Greenwich told reporters.
"I would say to whoever forms government ... this is legislation where you should respect people's conscience.
"It is an untenable position for the prime minister to say he won't move on this."
Introducing the bill for its final vote, Mr Greenwich thanked Premier Dominic Perrottet and Opposition Leader Chris Minns - neither of whom supported the legislation - for allowing a conscience vote.
"That has brought people together on both sides, to have a robust and difficult conversation," he said.
"Today, NSW passes a threshold of honesty and compassion.
"Honesty that not all people die well, and compassion that people in NSW with an advanced terminal illness can have the same end of life choices as people in every other state."
The bill passed the lower house just after midday to thunderous applause, after passing the upper house with amendments following a 12-hour debate.
It allows adults with a terminal diagnosis and up to six months to live to voluntarily end their life with assistance, with the approval of two independent doctors.
Go Gentle Australia founder Andrew Denton said it represented a revolution for end of life care in NSW.
"We haven't just moved NSW into the 21st century, we have moved it from the 13th century," Mr Denton said.
"This is not just a revolution of medical care.
"It's an evolution in our compassionate society."
Dying with Dignity NSW President Penny Hackett said it was a historic moment for people who had campaigned for decades to stop terminally ill people enduring prolonged suffering.
"We will now be the last state in the country to achieve this well overdue law reform," Ms Hackett said.
"This bill will give an immense sense of hope and relief to many people with a terminal illness who simply want to take back some control at the end of their life."
Steve Offner from Go Gentle Australia said it had been a 50-year fight to get the laws passed.
"So for many people in the community, it will be an incredible relief," he told AAP.
"It will be a moment of celebration.
"It will also be a bittersweet moment for many, given there are so many people for whom this law has just come too late."
Independent MP for Murray Helen Dalton, who co-sponsored the bill, said it was important the safeguards did not disadvantage regional people.
"In small towns, it's hard enough to find one doctor, let alone two."
She urged the government to increase funding for rural GPs.
Lifeline 13 11 14
beyondblue 1300 22 4636
Australian Associated Press
Sign up for our newsletter to stay up to date.