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.”

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

Get The 1600 newsletter

Get our inside look at the White House and goings on in the Donald Trump administration.

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.

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.

“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.

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

HIGHLIGHTS OF MEASURES APPROVED BY THE STATE LEGISLATURE

The bills will go to Gov. Andrew M. Cuomo for his signature or veto:

Delay the deadline for schools to have teacher evaluation plans approved by the state until Dec. 31, from Sept. 1, before schools lose extra state aid that is used as an incentive.

Extend mayoral control of New York City schools for one year, with some additional data reporting required from each school.

State takeover of funding for indigent legal services programs by 2023.

Spend more than $570 million to build and operate the first 1,200 units of supportive housing under a $20 billion Housing and Homelessness plan.

Allow “high performing” charter schools to switch their oversight body. That is expected to mean that more charters will be monitored by the State University of New York Board of Trustees, headed by appointees of Gov. Andrew M. Cuomo, rather than the state Education Department, headed by appointees chosen primarily by the Assembly’s Democratic majority.

$50 million more in construction money for SUNY and the City University of New York, in addition to $403 million provided in the state budget passed in April.

Extend state oversight of the New York Racing Association until Oct. 18, 2017. Cuomo and the Legislature took control of NYRA, which operates Belmont, Saratoga and Aqueduct race tracks, as part of the private entity’s emergence from bankruptcy in 2012.