Iowa lawmakers struck a last-minute deal early Saturday morning to expand the state’s limited medical cannabis program, approving legislation that would allow marijuana to be grown in Iowa and dispensed as an oil to seriously ill patients.

“There are sick Iowans out there that need relief, bottom line,” said the bill’s floor manager, Rep. Jarad Klein, R-Keota.

The legislation, unveiled in the Iowa House about 3 a.m. and given final approval by the Senate at 7 a.m., was among the final bills passed by the General Assembly before lawmakers officially adjourned for the year.

“There are many, many citizens, literally thousands of citizens, that could benefit from the use of this medication,” said Rep. John Forbes, a Democrat and pharmacist from Urbandale. “They’ll have access now to a treatment for debilitating diseases that are not very well treated sometimes with conventional medicine.”

Iowans currently are allowed to possess cannabis oil for the treatment of epilepsy. But it’s illegal to manufacture or distribute that oil in the state, and federal law prohibits its transportation across state lines. In practice, that makes it illegal for Iowans to obtain the product.

The current law, enacted in 2014, is scheduled to sunset in July. Advocates have pushed for a replacement program that allows the plant to be grown within state lines and prescribed to patients with a much wider range of medical conditions.

If approved by the governor, House File 524 would require growing, manufacturing and distributing companies to submit proposals to the state, and it would allow the Department of Public Health to approve up to two manufacturers and up to five distributors for operation. Those companies could only produce and sell cannabis oil with a tetrahydrocannabinol, or THC, content of up to 3 percent. THC is the psychoactive component of cannabis.

The bill also would expand access to the product to patients who have been diagnosed by an Iowa-licensed physician with Parkinson’s disease, cancer, multiple sclerosis, seizures, AIDS and HIV, Crohn’s disease and Amyotrophic Lateral Sclerosis, as well as most terminal illnesses that have a life expectancy of less than one year and untreatable pain.

A new Medical Cannabidiol Advisory Board would be established within the Department of Public Health to recommend adding or removing conditions from that list to the Iowa Board of Medicine. That board also could issue a recommendation to the Legislature to raise the 3 percent cap on the THC limits if necessary.

“We are leaving that door open for them to give us the advice,” Klein said. “But at the same time, we’re making sure that we’re not ceding our responsibility to have oversight on this.”

The bill passed in the House with bipartisan support on a vote of 83-11. The Senate took up the bill for debate shortly afterward, ultimately approving it on a 33-7 vote.

Sen. Thomas Greene, R-Burlington, a retired pharmacist, urged his colleagues to support the bill in the Senate.

“This is a step forward,” he said.

The Iowa Senate earlier in the week passed its own legislation expanding access to medical marijuana. Senate File 506 was much more expansive: It did not cap the THC levels, it would have allowed patients with about 20 different medical conditions access to cannabis oil, and it would have legally reclassified marijuana under state law.

But Republicans in the House took issue with that language, saying it was far too broad. They said they preferred to have medical experts overseeing certain decisions. The Senate on Saturday agreed to advance the House version of the bill, though many Democrats expressed frustration.

Sen. Joe Bolkcom, D-Iowa City, said that for most ailments covered by the bill, the medication has no more benefit than a baby aspirin.

“I am afraid it will provide a lot of false hope for the thousands of suffering Iowans who have petitioned us and really begged us,” Bolkom said, urging a no vote. “For sick Iowans, you won’t get much relief unless you get relief from hollow Republican talking points.”

Sen. Charles Schneider, R-West Des Moines, said he agreed the Senate version was superior to the bill approved by the House. But he said the legislation would expand the availability of cannabis oil to sick people and it will no longer force people to purchase the drug out of state.

“It’s not perfect,” he said. “But it is a good start, and a fitting way to end this legislative session.”