A Pennsylvania county’s policy barring people on probation from using medical marijuana is unlawful, the state Supreme Court has ruled in a high-profile test of the 2016 law legalizing medicinal uses of the substance.

The justices on Thursday unanimously held in the case, captioned Gass v. 52nd Judicial District, Lebanon County, that Lebanon County’s broad policy conflicted with immunities provided to patients under the Medical Marijuana Act. The court had taken up the matter under its plenary, or King’s Bench, jurisdiction.