A California judge on Tuesday threw out a 2016 state law allowing the terminally ill to end their lives, ruling it was unconstitutionally approved by the Legislature.

Riverside County Superior Court Judge Daniel Ottolia did not rule on the legality of allowing physician-assisted death, but he issued an oral ruling saying lawmakers acted illegally in passing the law during a special session devoted to other topics, said lawyers for supporters and opponents.

Ottolia kept the law in place and gave the state attorney general five days to appeal. Attorney General Xavier Becerra's office did not immediately respond to calls and emails seeking comment.

The Life Legal Defense Foundation, American Academy of Medical Ethics and several physicians challenged the law, which allows terminally ill adults to obtain a prescription for life-ending drugs if a doctor has determined they have six months or less to live. The plaintiffs say the law lacks safeguards to protect against abuse.

California is one of five states in which terminally ill people can end their lives. Oregon was the first to provide the option in 1997.

Since California approved the legislation, hundreds of terminally ill people have requested life-ending drugs, according to state figures and local advocates who track the prescriptions.

California health officials reported that 111 terminally ill people took drugs to end their lives in the first six months after the law went into effect June 9, 2016, and made the option legal in the nation's most populous state. The next report on how many people took the drugs is due in July.

"Our supporters, they've frankly expressed shock at this outcome. They're disappointed that this end of life option could be taken away," said John Kappos, an attorney representing Compassion & Choices, a national organization that advocated for the Legislature to pass the law.

Advocates argued if the law is suspended, people who qualified for the prescriptions will lose the option and be forced to suffer prolonged, painful deaths.

"The court went down a technical path saying we're not going to reach the merits...but the way it was enacted through a special session the court said was improper and therefore declared it unconstitutional," Kappos said.

The Democratic lawmakers who carried the original bill, Assemblywoman Susan Talamantes Eggman of Stockton and Sen. Bill Monning of Carmel, could not immediately say if they would try to pass the bill again.

Alexandra Snyder, an attorney and executive director of Life Legal Defense Foundation, said the judge ruled that lawmakers effectively "hijacked" a special legislative session that was called to address access to medical care and used it to pass their bill.

"It was a violation of the Constitution to basically slip in this suicide bill," she said, saying it set a dangerous precedent that undermines the legislative process. "Access to health care has no relationship to assisted suicide."

The state's attorney general's office, in responding to the suit, noted that medical professionals have the right to refuse to prescribe and dispense the drugs. Under the law, the terminally ill person must be able to self-administer the drugs.

The attorney general's office said in court documents that the act "provides comfort, support and an option to accommodate the very unique needs of terminally ill patients." It said the plaintiffs are wrong to second guess the Legislature's policy decisions.

In lobbying against the law before state legislators, opponents argued that hastening death was morally wrong, that it puts terminally ill patients at risk for coerced death by loved ones and could become a way out for people who are uninsured or fearful of high medical bills.

___

Associated Press writer Julie Watson contributed to this story from San Diego.