PHOENIX - A California woman whose marijuana was taken away by a Border Patrol officer is entitled to have it back, the state Court of Appeals ruled Thursday.

The judges rejected arguments by the Yuma County Sheriff's Department, which now has possession of the marijuana, that its deputies would be violating federal drug laws by giving Valerie Okun her marijuana back. Appellate Judge Diane Johnsen, writing for the unanimous court, said Okun is a legal medical-marijuana user, meaning the state has no right to take away her drugs.

Johnsen rejected concerns that deputies involved in returning Okun's drugs could wind up in legal trouble themselves.

"The sheriff is immune from prosecution under federal law for acts taken in compliance with a court order," she wrote.

In a prepared statement, newly elected Sheriff Leon Wilmot said his office is reviewing the ruling with the County Attorney's Office before deciding whether to seek Supreme Court review. Wilmot inherited the problem. It was his predecessor, Ralph Ogden, who fought the original order to return the drugs.

Okun was stopped nearly two years ago at a Border Patrol checkpoint along Interstate 8. Officers searched her vehicle after a dog alerted on it, finding marijuana and hashish.

The Border Patrol turned the matter over to county officials. But charges against her were dropped because she is enrolled in California's Medical Marijuana Program. Arizona's Medical Marijuana Act recognizes cards issued in other states.

Okun asked the court to return the three-fourths of an ounce of marijuana that was seized, but while the judge agreed, the Yuma County Sheriff's Office refused.

Attorneys for the sheriff said Arizona law requires any marijuana seized in connection with a drug offense be forfeited to the state. But Johnsen said the lawyers are missing the point: Okun had a right under Arizona law to possess the drug in the first place, a point which county attorneys concede.