After threatening a veto, Gov. Andrew M. Cuomo sat down with legislators to try to reach a last-minute deal to legalize marijuana for medicinal purposes. Shown here at SUNY Old Westbury on June 11, 2014. Photo Credit: Newsday / J. Conrad Williams Jr.

ALBANY -- State officials reached a deal late Tuesday on bills intended to curb the rampant rise of heroin use in New York, a source said.

The most significant measure would change insurance laws so as to get heroin addicts to in-patient treatment settings sooner, according to a memo outlining the package of legislation. Other measures would increase post-treatment services to prevent relapses, and increase awareness and prevention programs aimed at teens and young adults. There also are anti-crime measures, including stiffening penalties for illegal scripts and illegal opioid sales, and allowing law enforcement more access to a suspect's criminal history.

Gov. Andrew M. Cuomo and lawmakers also continued to negotiate a bill to legalize marijuana for medicinal purposes, after the Democrat governor threatened to veto it.

But time is growing short for lawmakers to reach consensus before they adjourn for the year.

The medical marijuana bill was one of many that were under discussion on what was supposed to be the third-to-last day of the 2014 legislative session. Cuomo said marijuana, anti-heroin and teacher evaluation bills were his main priorities, though rank-and-file legislators were still trying to pass legislation on red-light cameras, education tax credits, Family Court judges and Long Island water quality.

All the while, hundreds of protesters marched in the State Capitol's halls, demanding action on bills to combat human trafficking, change the mental health system and raise the minimum wage, among other issues.

The governor, once an opponent of medical marijuana, began the day saying he would veto a medical marijuana bill as currently drafted by the legislature. Cuomo, who is running against Republican Rob Astorino this fall, said he still has "significant concerns" about the dispensing of medical marijuana so it won't be sold or used illegally.

He wants to limit the number of dispensaries statewide to four (instead of 20), authorize the program for just five years (instead of no sunset) and shorten the list of conditions that would qualify for treatment.

In the afternoon, Cuomo huddled with the chief Assembly and Senate sponsors of the marijuana legislation for more than an hour. Though no agreement was reached, the tone was noticeably more cordial than a day before, when the governor and legislators traded jabs.

"We're in the process of working toward a bill the governor can support," said state Sen. Diane Savino (D-Staten Island).

The Assembly and Senate appeared ready to agree on a bill to add 25 Family Court judges around the state, including one apiece for Nassau and Suffolk counties. Both houses still have to pass the bill before adjournment, and Cuomo also would have to approve.

Chances for a "Long Island Water Quality Control Act" looked murky. It would require the state to establish criteria for safeguarding Island watersheds and guide farmers on pesticide and fertilizer use. State Sen. Kenneth LaValle (R-Port Jefferson) said farmers groups continue to oppose the proposal.