Pennsylvania on Sunday became the 24th US state to legalize a comprehensive medical marijuana program.

The Democratic governor, Tom Wolf, signed the bill into law in the afternoon, surrounded by a jubilant crowd of supporters at the Capitol building in Harrisburg.

“Marijuana is medicine and it’s coming to Pennsylvania,” said Democratic state senator Daylin Leach, the bill’s cosponsor.

The bill’s drafters say it could take two years to write regulations and get retailers opened, but a provision allows parents to legally administer medical marijuana to their children before the bill takes effect in a month.

The bill sets standards for tracking plants, certifying physicians and licensing growers, dispensaries and physicians. Patients can take marijuana in pill, oil, vapor, ointment or liquid form, but will not be able to legally obtain marijuana to smoke or grow.

Senator Mike Vereb, a Republican, called on lawmakers to take on what he called “the No 1 killer in Pennsylvania” – opioid abuse.

Tom Wolf speaks at a ceremony where he signed the medical marijuana bill. Photograph: Daniel Zampogna/AP

“Opioid abuse has no party, has no color, has no religion,” Vereb said. “Let’s face it, that’s the killer. What we’re doing today is the healer.”

Among those celebrating the victory was Dana Ulrich, who has fought for legal access to the drug in the belief that it would help her eight-year-old daughter Lorelei, who has numerous seizures every day.

“I never doubted for one second that this day would come,” she told the crowd, thanking patient advocates and caregivers as well as lawmakers and the governor.

“When you get a group of truly dedicated people together that have the same goal and the same mind and the same hearts, you can achieve anything.”

Wolf called it “a great, great day for Pennsylvania, but more important, a great day for Pennsylvanians”. He said he and lawmakers were responding not to a special interest group or to campaign contributors, but to “a real human need”.

“When you have people who represent a cause as eloquently and in as heartfelt a way as the advocates for this have done, it shows that we can actually get something done that means something,” Wolf said.