ALBANY — The New York Senate passed a bill legalizing access to medical marijuana on Friday, a day after Gov. Andrew M. Cuomo and legislative leaders announced the agreement on a seven-year pilot program to provide the drug to sick New Yorkers.

The bill passed 49 to 10.

The Assembly, where the majority Democrats had long supported the concept, had passed the bill during an overnight session. And Mr. Cuomo is expected to sign the bill soon. It would be effective immediately, though the bill’s regulations and implementation could take up to 18 months.

The passage came after days of intense negotiations between the Legislature and Mr. Cuomo, a Democrat, who had proffered a more restrictive system earlier this year that was roundly criticized as unworkable for thousands of potential patients.

The new agreement included a major demand of the Cuomo administration: that no smoking of the drug would be permitted, though a variety of other options — including edibles and tinctures — would be. Patients would also be allowed to inhale if the drug was vaporized, similar to e-cigarettes.