SALT LAKE CITY -- Against all odds, a medical marijuana bill is advancing in the Utah State Legislature.

The Utah State Senate voted 17-12 to approve Senate Bill 73, sponsored by Sen. Mark Madsen, R-Saratoga Springs. It allows patients with certain ailments (such as cancer, AIDS, epilepsy and chronic pain) to use marijuana edibles, extracts and oils under the direction of a doctor.

Madsen said during Thursday's debate his latest version of the bill clears up the definition of "cannabis", and adds child-proofing standards, dosing regulations and other considerations.

FOX 13 News' Ben Winslow reports a huge cheer erupted among those watching from the gallery as the vote was passed, and the topic has been the subject of several heated debates this legislative session.

Outside the Senate, hugs and cheers from patients and medical marijuana advocates. @fox13now #utpol pic.twitter.com/yR3xLNdhI6 — Ben Winslow (@BenWinslow) February 25, 2016

Some supporters of the bill, like Enedina Stanger, were emotional after the vote.

"I am so excited, this is such a miracle, this is all because of God," Stanger said through tears. "It was a hard battle, but it was just because of the miracles and by the love of human beings that we got this through today. I'm so excited."

See the vote breakdown for SB73:

The bill will now go to the Utah House of Representatives for a vote. Advocates for the bill say the measure will face opposition in the house, but proponents said this most recent vote gives them hope that they can rally the necessary 38 votes to get the bill passed.

A robust debate took place earlier this week for SB73, click here for details.

Madsen watered down his bill after opposition from Senate colleagues and The Church of Jesus Christ of Latter-day Saints. On Monday, the LDS Church softened its opposition to SB73, but still didn't give its blessing to the legislation.

Earlier this week, the Senate voted 18-8 to pass Senate Bill 89, sponsored by Sen. Evan Vickers, R-Cedar City, a competing bill that would allow for an extract to treat medical conditions. That bill, which is more narrow in scope than SB 73, also goes to the House for consideration.