LOS ANGELES — A California appeals court overturned a lower court order that had imperiled the state’s assisted suicide law, but a longer legal fight may loom because the ruling skirted the larger issue of whether the legislation was unconstitutional.

A three-judge panel of the 4th District Court of Appeals in the city of Riverside on Tuesday did not rule on the merits of the case because it found doctors opposed to the law had no right to sue to block the law. The court said the doctors failed to show they were harmed because they could choose not to help terminally ill patients die.

The End of Life Option Act allows adults to obtain a prescription for life-ending drugs if a doctor finds they have six months or less to live.

The ruling reversed Riverside County Superior Court Judge Daniel Ottolia's judgment in May that declared the law unconstitutiona because it was adopted during a special legislative session that was supposed to address improving the medical system and health of Californians.

The appellate ruling written by Presiding Justice Manuel Ramirez has no immediate impact on the current status of the law because the appeals court had put the trial court judgment on hold during the state attorney general's legal challenge.

News that the lower court ruling had been reversed buoyed advocates of doctor-supported death.

"Our patients will be tremendously relieved," said Dr. Catherine Sonquist Forest, a family physician in Northern California who has six terminally ill patients considering the option. "Thousands across the state will find great solace in knowing this option is there."

The ruling is probably not the last word on the matter and could set the stage for future legal actions. The case was sent back to the lower court and the lawsuit could be amended and refiled.

The court even spelled out how groups challenging the law might be able to show harm to plaintiffs.

For example, a district attorney who wanted to prosecute a doctor for helping a patient die or a hospital or medical group that sought to discipline an affiliated physician who assisted a death might be able to establish standing, the court said.

The Life Legal Defense Foundation, which represented the doctors, said it was disappointed and would consider its options. Other opponents of the law criticized the decision.

"Assisted suicide is not health care and places countless Californians at risk of deadly harm," said Matt Vallière of the Patients Rights Action Fund. "Sadly the court's ruling in this case ... fails to protect vulnerable patients whose care has been compromised by this dangerous public policy."

Supporters of assisted suicide said the ruling would strengthen their defense of the law in the future.

"But the harsh reality is this case is likely to last several more years because the plaintiffs are hell-bent on depriving ... terminally ill Californians ... (of) a peaceful death, free of unbearable suffering," said attorney John Kappos, who represented Compassion & Choices, a group that supported the law.

While two justices ruled only on the issue of standing, Justice Marsha Slough dissented in part because she said the appellate panel should have ruled on the merits of the case and found the law was constitutional.

Slough said it was not a stretch for the Legislature to consider assisted suicide as an extension of a discussion on the efficiency of the health care system. She said there was no reason to "drag this case out" before finding lawmakers acted within their authority.

"We have a responsibility to expeditiously disperse the uncertainty this litigation has created for countless patients, family members, and loved ones, as well as physicians and workers in the health care sector," Slough wrote.

In 2017, the first full year assisted suicide was legal, 374 terminally ill people took drugs to end their lives, California health officials said.

The District of Columbia and six other states — Oregon, Colorado, Montana, Vermont, Washington, and Hawaii — also allow assisted suicide.