Virginia Gov. Terry McAuliffe (D) signed legislation Thursday allowing the use of medical marijuana oil for people suffering from severe epilepsy.

As marijuana becomes legal in the District, advocates in neighboring Virginia said they thought even this first small step toward medical use would never be taken.

“They said hell would freeze over before this would ever pass,” said Robert Smith, whose 14-year-old daughter, Haley, has daily seizures — and suffered one during a committee hearing on the bill this year.

“Seeing how horrific it is, it softened a lot of hearts,” he said.

The Smiths are planning to try the oil, which for many patients has dramatically reduced seizures without the debilitating side effects of epilepsy drugs, as soon as the law takes effect in April. Along with other families, they began lobbying for the bill in January 2014, pressing research and personal stories on skeptical politicians.

Before signing the bill, the governor said that epilepsy is an issue close to his heart. The best man at his wedding, former California congressman Anthony Coelho, has epilepsy and is chairman of the board of directors of the Epilepsy Foundation.

“No state should have laws . . . where our great Virginia residents might say, ‘I have to move to another state because we can’t provide the treatment for our children,’ ” McAuliffe said. Now, he said, “everybody will stay in Virginia.”

Beth Collins of Fairfax is one such parent, who temporarily moved with her teenage daughter Jennifer to Colorado to use marijuana oil. While the treatment was effective, Jennifer told lawmakers that she missed her friends, her school and the rest of her family while isolated in Colorado Springs. They moved back to Fairfax late last year. The mother and daughter cried watching the governor as the bill was signed.

“We’re so happy that Jennifer can now stay here in Virginia where she belongs,” said Beth Collins. “We were told it couldn’t be done, but I never doubted that it could.”

Some lawmakers cautioned that the bill’s passage was not a sign of a larger movement to relax marijuana laws in Virginia. Others celebrated what they saw as a big moment. Lt. Gov. Ralph Northam (D), who announced this week that he is running for governor in 2017, tweeted: “@GovernorVA Thank you for signing this bill in to law, it will make a huge difference in the lives of these children & families!”

Hurdles remain. The law McAuliffe signed provides what is known as an “affirmative defense” from prosecution for anyone with a doctor’s certification that marijuana oil is being used to treat in­trac­table epilepsy, and allows doctors to issue such certifications. In other words, possessing the pot oil will still be technically illegal — but prosecutors will be prohibited from prosecuting such cases.

Also, cultivating marijuana remains illegal in Virginia — lawmakers showed no interest this year in changing that law — so the new measure does not provide for a legal means to produce the oil within state borders. And because possession remains illegal under federal law, lawmakers could not find a way to legalize transport of the oil across state lines — leaving it unclear how patients will procure it.

“The federal government has got some work to do,” said Del. David B. Albo (R-Fairfax), who sponsored the bill along with Sen. David W. Marsden (D-Fairfax). Collins and other parents are lobbying the Obama administration to reclassify marijuana as a less dangerous drug.

Medical marijuana for the treatment of cancer and glaucoma has been technically legal in Virginia since 1979, but there has never been a legal avenue for prescription or distribution of the drug.

McAuliffe has repeatedly said that he is open to any legislation legalizing marijuana use when scientific evidence shows it has a medical value.