OTTAWA — The Supreme Court of Canada on Friday struck down laws banning physician-assisted suicide for patients with “grievous and irremediable” medical conditions.

The unanimous decision, which reverses the position taken by the court 22 years ago, came more quickly than expected and might become an issue in federal elections to be held this year.

“The prohibition on physician-assisted dying infringes the right to life, liberty and security of the person in a manner that is not in accordance with the principles of fundamental justice,” the court wrote, adding that an absolute ban was not needed to ensure that vulnerable people are not coerced “to commit suicide at a time of weakness.”

The decision, which follows hearings last fall, comes at a time when Canadians are widely debating assisted dying. In June, Quebec passed legislation that would allow the practice starting at the end of this year. Until the Supreme Court ruling on Friday, that legislation seemed likely to be overturned under federal criminal law.