Victoria's controversial voluntary euthanasia legislation has been passed in the Lower House of Parliament after a marathon debate that lasted more than 24 hours.
The Voluntary Assisted Dying Bill passed 47 votes to 37, after a conscience vote.
The majority of Labor MPs backed the bill, along with two Greens, two independents and a handful of Coalition MPs.
It will now go to the 40-member Upper House, where the numbers are also tight, for debate in a fortnight.
If it gets through the Upper House, terminally ill people over the age of 18, in severe pain and with only a year to live will be able to access lethal drugs.
Premier Daniel Andrews said he was proud of the efforts of Health Minister Jill Hennessy, who was one of the driving forces behind the bill.
"This has been talked about for a very, very long time and I think we have brought a seriousness and respectfulness to this debate that I think is very important," he said outside Parliament.
"And now we've got this done."
Euthanasia advocate Andrew Denton was among members of the public in Parliament to watch the vote.
Deputy Premier James Merlino is among Government MPs who oppose the bill.
Push for changes was not needed: Andrews
Tempers flared in the chamber during the protracted debate, as those opposed to the bill tried to pass more than a dozen clauses and hundreds of amendments.
"I would have preferred that we ended and we came back today but it was always going to be a long bill," Opposition Leader Matthew Guy said.
"I think it is more fluid than people expect and I think it is probably closer than people expect."
Speaking after the vote, Liberal MP Kim Wells defended the tactics.
"I know people have been critical of it, that we were putting up amendments that we knew we would get defeated on, but that is not the point," he said.
"This is a democracy, it was a conscience vote."
The amendments called for legislative changes such as the public release of euthanasia statistics, prohibitions on advertising for voluntary assisted dying and stricter requirements around psychiatric assessments.
Politicians on both sides had been escaping to their offices to nap in between votes on various amendments.
Mr Andrews stood by the decision to reject every change put forward.
"None of them needed to be supported and they were not. The support for the amendments got smaller and smaller as the debate went on," he said.
"Some of these amendments wouldn't have done any harm as such, but they're not needed because there are other laws in Victoria.
"You don't have to have every single law written into this bill — it doesn't exist on its own."
Law won't take effect before 2019
Mr Andrews has described the laws — which were designed by an expert panel including former medical association head Brian Owler — as the most conservative euthanasia regime in the world.
The legislation includes a range of safeguards. Patients would have to make three requests and see specially trained doctors, and coercing someone to seek a medically assisted death would become a crime.
In most cases — estimated to be about 150 a year — the lethal dose would be self-administered. But in some cases where patients cannot administer the drug, doctors could be involved.
If passed, the legislation will not come into effect for 18 months to allow for its implementation.
Unlike when the Northern Territory introduced euthanasia laws, only to see them overruled by the Howard government, Victoria's laws cannot be overturned by the Commonwealth.
Polling has consistently shown widespread support for euthanasia for the terminally ill, including last year's ABC Vote Compass, which found three out of four Australians backed the idea.