RICHMOND — The General Assembly has passed legislation to allow use of two derivatives of the marijuana plant for treating severe epilepsy.

It’s the first effective medical marijuana legislation to win approval in Virginia, according to its House sponsor, Del. Dave Albo.

Albo’s measure, unanimously passed by the House on Tuesday, allows possession of cannabidiol oil or THC-A oil with written certification by a doctor that it is needed for treatment of intractable epilepsy.

Lawmakers were moved by emotional testimony from parents of children with epilepsy who have suffered debilitating side effects from taking legal drugs.

A similar bill was approved by the state Senate last week 37-1.

Medical marijuana for treatment of cancer and glaucoma is technically legal in Virginia, but that law has been ineffective because it relies on a doctor’s prescription, Albo said. Doctors are prohibited by federal law from prescribing marijuana.

The epilepsy legislation skirts that problem by requiring only a certification, not a prescription.

“If you’re a kid with intractable epilepsy and you get caught with marijuana oil, I’m not going to make you a criminal,” Albo said.

Albo, a Fairfax County Republican, said his bill originally would have established the same legal structure for marijuana used in treating cancer and glaucoma, but he encountered opposition from lawmakers concerned that the drug would be diverted for recreational use.

The marijuana oils used in treating epilepsy lack the plant’s intoxicating properties.

A separate measure to decriminalize marijuana possession in Virginia was killed in a Senate committee last month.