State lawmakers on Friday put the finishing touches on a sweeping package of changes to rent control in New York, which allow communities outside of the New York City area to opt in to regulations designed to protect tenants.

The state Senate approved the package, announced earlier this week by the legislative leaders, 36-26. The Democratic-controlled Assembly followed suit soon after, 95-41.

Gov. Andrew Cuomo signed the bills shortly after they achieved final passage.

The governor, who faintly praised the agreement earlier this week at a news conference, released a more celebratory statement on Friday.

“At the beginning of this legislative session, I called for the most sweeping, aggressive tenant protections in state history. I’m confident the measure passed today is the strongest possible set of reforms that the Legislature was able to pass and are a major step forward for tenants across New York,” Cuomo said.

“As the former Secretary of Housing and Urban Development under President Clinton, I know full well the importance of affordable housing and with the existing rent laws set to expire tomorrow, I have immediately signed this bill into law – avoiding the chaos and uncertainty that a lapse in these protections would have caused for millions of New Yorkers.”

For Democrats who gained control of the state Senate, the passage and forging of the deal was a victory. The measures permanently extend rent control laws and allow local governments to opt in and adopt their own local-level regulations.

The measures make it harder for landlords to evict tenants when rent is increased and raise rents when capital improvements are made to a dwelling.

“We made a commitment that the new Senate Democratic Majority would help pass the strongest tenant protections in history,” Senate Majority Leader Andrea Stewart-Cousins said. “The legislation we passed today achieves that commitment and will help millions of New Yorkers throughout our state. I thank my partner in legislative leadership, Speaker Carl Heastie and the Chair of the Senate’s Housing, Construction and Community Development Committee, Senator Brian Kavanagh for his leadership on this issue.”

Both Heastie and Stewart-Cousins announced the two-way deal on Wednesday, well ahead of the Saturday deadline for the current laws to expire.

The measures are expected to face a court challenge from real estate interests in court.

“For too long, power has been tilted in favor of landlords. But today we were able to level the playing field and bring stability to tenants across New York State, whether they live in an apartment in the Bronx, a single family home in Nassau County or a manufactured home upstate,” Heastie said. “The Assembly Majority will continue working to ensure every New Yorker can find quality, affordable housing.”