The City Council on Thursday passed the Community Opportunity to Purchase Act, a controversial bill that would give nonprofits first dibs at purchasing certain distressed residential buildings in the five boroughs.

The bill, which had been watered down from its original version, passed with a vote of 38-9, with two abstentions.

As the city battles a housing crisis amid record-low vacancy rates, the bill’s backers have argued it could help some city dwellers by providing affordable homes, instead of their being priced out by developers looking to “flip” dilapidated properties.

The legislation, which is intensely opposed by real estate groups, has cycled through a yearslong saga since its first version was introduced in 2020.

Last year, the bill was passed by the Council but vetoed by then-Mayor Adams on his way out of office. The Council then in January declined to override the veto. Menin cited concerns the Council could be sued over it by real estate groups, in addition to the bill not having a supermajority of support. The measure was reintroduced by Councilmember Sandy Nurse earlier this year.

Council members call for probe of "deadlocking" of seriously mentally ill detainees on Rikers Island

Luiz C. Ribeiro for NY Daily News

City Council member Sandy Nurse (Luiz C. Ribeiro for NY Daily News)

The version of the bill passed Thursday covers around 2,100 buildings citywide with four or more units — narrower in scope than the 10,000 buildings covered in the version passed last year — with property owners required to provide a 90-day window giving nonprofits the first chance to buy them.

“That is why a lot of different, whether it be industry or Council members who initially had opposed it, are now more comfortable with this new version, and we were able to address some of the legal issues that the Law Department had raised, and we made it a more targeted bill,” Menin said at a press conference Thursday.

Spokespeople for Mamdani did not immediately comment on the bill’s passage, but the mayor has been vocally supportive of COPA, including it in his housing plan released earlier this year.