The legalization of medical marijuana moved a step closer to reality in Connecticut after a Wednesday vote by the State House of Representatives.

The House voted 96 to 51 to pass a bill that would legalize medical marijuana in the state following an afternoon of debate and a last-minute attempt by opponents to block it. If the legislation clears the Senate, Gov. Dannel Malloy has said he will sign it.

Under the bill, patients suffering from certain illnesses like AIDS or cancer could obtain a one-month supply of marijuana for medical use with a doctor’s permission. The bill would also license and regulate medical marijuana producers.

“We’re authorizing physicians to make smart medical choices with how they treat their patients,” said Rep. Roland Lemar, a freshman Democrat representing New Haven. “It’s been proven over and over that marijuana has positive side effects that other drugs have been unable to offer.”

Opponents of the bill, meanwhile, argued that the bill would violate federal laws that prohibit marijuana use and that its language is too loose in terms of the illnesses it would make eligible for treatment with medical marijuana. State Sen. Robert Kane, a Republican from Middlebury, said he does not support the bill because it covers “less severe” illnesses like chronic back pain, and because of the “direct conflict” between the bill and federal law.

While Kane acknowledged that states such as California and Colorado have not yet faced prosecution over their laws permitting medical marijuana, he said they could be challenged at “any time” in court. Both President Barack Obama and Mitt Romney’s campaign have said they will start prosecuting states that permit medical marijuana, he added.

State Senators Michael Mclachlan and Toni Boucher, Republicans from Danbury and Ridgefield respectively, solicited a letter from David Fein, Connecticut’s U.S. Attorney, emphasizing the problems they said would result from the bill’s contradiction of federal law.

“Growing, distributing, and possessing marijuana” is illegal under federal law, Fein wrote in the letter, “regardless of state laws permitting such activities.”

Because the bill would violate federal law and undermine federal attempts to regulate marijuana, he wrote, the U.S. Department of Justice could consider “civil and legal” penalties against anyone involved in medical marijuana dispensaries.

Proponents of legalization, though, said the clash with federal law has not impeded other states’ efforts to provide medical marijuana, such as that of New Jersey, which passed a similar bill in early 2010 and has not faced any federal action on the issue. Learning from these examples, Lemar said, has helped the General Assembly put together a bill that could survive a federal challenge.

“We put in restrictions that should protect any users or suppliers or dispensers from federal law,” said State Senate Majority Leader Looney, a New Haven Democrat. We believe we’ve crafted a law that protects individuals of Connecticut.”

The bill also has the support of a majority of Connecticut residents, according to a March Quinnipiac University poll. Of the poll’s 1,622 respondents, 68 percent supported legalizing small amounts of marijuana for use by patients with chronic illnesses, with only 27 percent saying they were opposed.

The state legislature has brought up a medical marijuana bill in eight of the past 10 years, but has only passed it passed once, in 2007, when it was vetoed by then-Gov. Jodi Rell, a Republican.

Last June, the legislature passed a bill decriminalizing the possession of less than half an ounce of marijuana. Under the previous law, first-time offenders could face a $1,000 fine and up to a year in jail.

The medical marijuana bill now heads to the State Senate, where Lemar said it will likely be debated sometime next week. Lemar said the “votes are there” for the Senate to pass the bill, which has more political support in Hartford than the decriminalization bill enjoyed last year.

Medical marijuana is currently legal in 16 states, including Maine, Vermont and Rhode Island.