The moms won.

Iowa lawmakers early Thursday morning approved legislation legalizing the possession and use of marijuana oil for the treatment of epilepsy, capping one of the most unexpected public policy developments in recent state history.

After appearing all but dead in the waning hours of the 2014 legislative session, a bill allowing patients with intractable epilepsy to use the substance known as cannabidiol was brought to the House floor at 3:20 a.m. on Thursday and approved less than 20 minutes later.

The Senate approved the House's language on a 38-8 vote a short time later, sending the bill to Gov. Terry Branstad, who has indicated a willingness to sign it..

The passage marks a stunning victory for a group of mothers of children with epilepsy who lobbied lawmakers vigorously for months and changed the minds of several lawmakers who had been staunch opponents of medical marijuana.

"What we're offering today is hope for these families, that they can finally get some access to something that can help them," said Rep. Bob Kressig, D-Cedar Falls.

The bill approved Thursday decriminalizes possession of cannabidiol for epileptic patients and their caregivers who receive a neurologist's recommendation and obtain a state-issued ID card. The doctor must practice in Iowa, and caregivers must be designated by the recommending doctor.

Production and sale of the oil is not legal under the bill, however, meaning patients or caregivers will have to obtain it elsewhere and bring it back to Iowa. Possession of the oil will be limited to 32 ounces – roughly a six-month supply.