ALBANY — For the fifth time in seven years, the State Assembly on Tuesday passed a bill legalizing medical marijuana, backing a measure that would far surpass a program Gov. Andrew M. Cuomo announced this year.

But with less than four weeks left in the legislative session, the prospects for passage in the State Senate remained uncertain.

The bill allows the possession and use of up to two and a half ounces of marijuana by seriously ill patients whom doctors, physician assistants or nurse practitioners have certified. It permits organizations to establish dispensaries to deliver the drug to registered users and their caregivers, part of what advocates call a “seed to sale” system meant to prevent abuse or illegal use.

“There are tens of thousands of New Yorkers with serious, debilitating, life-threatening conditions whose lives could be made more tolerable and longer by enacting this legislation,” said Assemblyman Richard N. Gottfried, a Democrat from Manhattan who heads the Health Committee and sponsored the bill.