Bill 52 carried the day by a 94-22 majority in what was a free vote for members of the national assembly.
The legislation is officially dubbed "an act respecting end-of-life care."
It stipulates that patients themselves would have to repeatedly ask a doctor to end their lives on the basis of unbearable physical or psychological suffering. They would have to be deemed mentally sound at the time of the requests.
The federal government has said it could challenge the legality of the legislation.
Assisted suicide and euthanasia are illegal under Canada's Criminal Code and Ottawa has insisted it has no intention of changing that.
Quebec politicians have argued that delivery of health-care services falls under provincial jurisdiction and has said it is on solid legal footing.
The bill was originally introduced by the previous Parti Quebecois government last year but wasn't passed by the time then-premier Pauline Marois called the April 7 election in early March.
The legislation, which had all-party support, was resurrected when the national assembly resumed sitting following the Liberals' election victory.
"This is a law for people at the end of life and their families, but it is also a law for all Quebecers who want to have assurances that if the worst were to happen, they will be taken care of in the best way possible," the PQ's Veronique Hivon, who sponsored the bill, said Thursday.
The bill had already passed numerous hurdles, including highly divisive public hearings in 2010 and 2011.
A report from members of the legislature in 2012 suggested doctors be allowed in exceptional circumstances to help the terminally ill die if that is what the patients want.
A panel of experts later concluded that provinces had the legal jurisdiction to legislate in matters of health.
The legislation has three main components — it aims to expand palliative care; sets protocols for doctors sedating suffering patients until they die naturally; and offers guidelines to help patients who want to end their pain.
It refers to medically assisted death with a doctor administering medication to a terminally ill patient if they meet a host of requirements, including filling out a consent form and gaining the written approval of two doctors.
"The adoption of this bill is four-and-a-half years of work, it's four-and-a-half years of dialogue with the public, four-and-a-half years of compassion," Health Minister Gaetan Barrette said Thursday.