ALBANY — The tense, extended 2016 state legislative session ended early Saturday as lawmakers approved the return of online fantasy sports for money, requirements for water testing for lead in schools, a new tool to combat abandoned “zombie” homes and an ethics package months after an unprecedented corruption convictions of former top leaders.

“This agreement closes the door on an extraordinarily productive session focused on the economic and quality-of-life issues facing New Yorkers and their families, and the need to provide our kids with real and meaningful opportunities for the future,” said Senate Majority Leader John Flanagan (R-East Northport).

The measures were passed only after two marathon sessions that went past 5 a.m. Saturday. Passage came after Gov. Andrew M. Cuomo issued “messages of necessity” to suspend the three days public review of all bills required by the state constitution.

After midnight Saturday, Sen. John Bonacic (R-Middletown) was in the rare position of having to round up votes from the Democratic minority conference to pass his bill to legalize fantasy sports contests for money. He met with Democrats for more than two hours in private before the bill passed at 2:15 a.m.

Bonacic called the online activity “sports,” and said it was not a “game of chance,” which would be illegal in New York. He said the games will be well regulated and provide $5.8 million a year in revenue. But he failed to sway any members of his Republican majority on an issue that prompted one of the biggest lobbying fights in Albany in years.

Sen. Liz Krueger (D-Manhattan) spoke for a bipartisan group of legislators who are uncomfortable with the use of casinos, gambling and alcohol sales as economic development and tax revenue tools.

“If it looks like a duck, it swims like a duck, it quacks like a duck, it’s a duck,” Krueger said. “This is another gambling bill.”

advertisement | advertise on newsday

Still, fantasy sports aren’t yet a sure bet.

Cuomo didn’t join in the Assembly-Senate deal to restore fantasy sports after Attorney General Eric T. Schneiderman halted it as he investigated the possibility of illegal gambling. Cuomo has another chance to weigh in on the issue by either signing the measure or vetoing it.

Bonacic said on the Senate floor that Cuomo was supportive, but a Cuomo spokesman didn’t respond to a request for comment.

The Legislature also approved a package of ethics measures following a deal with Cuomo Friday night.

The measures require greater disclosure of the names of big-money campaign donors; greater disclosure and penalties for violating lobbying laws; measures to ensure candidates don’t coordinate with “independent expenditure” groups and political action committees; and strip pensions from elected officials and top policy makers convicted of corruption.

Former Senate Majority Leader Dean Skelos (R-Rockville Centre) and his son, Adam, and former Assembly Speaker Sheldon Silver (D-Manhattan) were convicted of federal corruption charges six months ago.

Skelos is eligible for a $95,000 annual pension and Silver is eligible for $79,000 a year.

Dean and Adam Skelos are appealing.

The pension measure starts a process that is expected to result in a voter referendum on the issue in 2017.

Sen. Todd Kaminsky (D-Long Beach) was able to help pass the pension forfeiture bill that he had written months before when he was an Assembly member.

advertisement | advertise on newsday

“Finally, taxpayers will receive some justice because dirty politicians will lose their pensions,” said Kaminsky, a former federal prosecutor who won Skelos’s seat in a special election in April.

Lawmakers said another measure will help reduce the number of zombie properties on Long Island and statewide that are in the foreclosure process and have been abandoned by owners.

The measure requires banks to maintain the homes they intend to own and to maintain vacant and abandoned property before foreclosures are complete. The legislation also creates an expedited foreclosure process for vacant and abandoned homes, a Consumer Bill of Rights to keep homeowners informed of their rights in foreclosure proceedings and a hotline to report unattended zombie properties.

After a long fight with school districts over cost, the legislature led by Senate Education Committee Chairman Carl Marcellino (R-Syosset) agreed to require regular testing of water for lead in drinking water and kitchens in schools.

School districts, through their lobbyists in the state School Boards Association, at first had pressed for the testing to be voluntary and then expressed concern that districts would have to pay a share of remediation.

advertisement | advertise on newsday

Under the bill, districts will have to pay a percentage of the cost, but less than half. The share will vary by school district.