California prison inmates who possess small amounts of marijuana are not guilty of a felony crime, according to an appeals court, which reasoned that because it's legal to have small amounts of pot in the state, the same is true inside its prisons. But the justices also said it's still illegal to smoke or ingest cannabis in prison.

The ruling from a panel of the 3rd District Court of Appeals in Sacramento overturns the convictions of five inmates who had been found guilty of possessing marijuana — convictions that added more prison time to their sentences.

"The plain language of Proposition 64 is clear," a panel of three justices said, referring to the 2016 initiative legalizing recreational marijuana use. They concluded that "possession of less than one ounce of cannabis in prison or a similar penal institution is not a felony."

In response to the ruling, the California Department of Corrections and Rehabilitation emphasized that inmates are still banned from smoking or ingesting marijuana in its prisons.

"While the court's decision is still under review, we want to be clear that drug use and sales within state prisons remains prohibited," said CDCR Press Secretary Vicky Waters. She added that the agency will "evaluate this decision with an eye towards maintaining health and security within our institutions."

Despite their conclusion that possessing cannabis does not constitute a felony, the court said prison authorities could still ban marijuana possession "to maintain order and safety in the prisons and other penal institutions."

The mixed decision was met with confusion among both prosecutors and criminal defense attorneys, even as some acknowledged that it is a step toward adjusting criminal law to reflect recreational marijuana's legal status in California.

"If you're doing two years on a robbery, it does seem like a lot to have eight years added for possession of less than an ounce of marijuana," defense attorney Dan Olsen told Sacramento's Fox 40 TV news.

In the 20-page opinion written by Presiding Justice Vance W. Raye, the appeals court said Attorney General Xavier Becerra's office "takes a huge leap" in arguing that possessing small amounts of marijuana is legally banned in prison, despite the sweeping and plainly stated changes to California's drug laws.

"The argument flies in the face of the plain language of the statute and common sense," Raye wrote.

The justices noted the unambiguous language of the state's marijuana law — which maintains bans on using the substance under certain circumstances. They also agreed with the defendants' contention that while smoking and/or ingesting cannabis in prison is specifically prohibited, the law leaves the door open to other methods of using cannabis. Those methods, they added, could include vaping or applying topical oils.

The attorney general's office had argued that the law resulted in an "absurdity" that would essentially legalize the use of a controlled substance in prisons and encourage drug smuggling.

But disagreeing with a drug policy decision isn't enough of a reason to declare a law to be absurd, the court said.

"The question of law we review ... is whether the plain language of the statute leads to an absurd result. We conclude it does not," Raye wrote. "A result is not absurd because the outcome may be unwise."

Becerra's office has not yet said whether it plans to appeal the ruling, The Associated Press reports.

The appeals court also suggested that new legislation, or even a new referendum, could ease some of the confusion over marijuana policies in California prisons.

"The remedy for clearly written language that achieves a dubious policy outcome is not judicial intervention but correction by the people or the Legislature," Raye wrote.