Co-op City, home to 55,000 residents in the Bronx, will remain affordable for decades to come after the closing of a mammoth $621.5 million loan.

The Wells Fargo loan to RiverBay Corp., which controls Co-op City, is the largest ever insured under the Department of Housing and Urban Development’s Sec. 223(f) program, which protects lenders against loss on mortgage defaults at multifamily properties.

It is also the first time the program has been applied to a cooperative development, according to officials.

The loan will be used to refinance the current debt on the state’s largest Mitchell-Lama project and keep the development affordable for another 35 years.

Co-op City is so large that if it was incorporated, it would be the 12th largest municipality in the state. “It is hard to exaggerate the critical role it has played for over 40 years in keeping housing in New York state and New York City affordable,” said Gov. Andrew Cuomo in a statement.

Federal, state, and city agencies collaborated to jointly insure the loan.

The Mortgage Insurance Fund of the State of New York Mortgage Agency, which is part of New York State Homes and Community Renewal, and the city’s Housing Development Corp. will provide credit support with $55 million and $15 million coverage of the loan, respectively.

Because of today’s low interest rates, the refinancing of the existing debt will save Co-op City and its residents $150 million over the 14-year remaining term of the current loan and eliminate refinancing risk should rates rise, said Alan Wiener, managing director of Wells Fargo Multifamily Capital.

Loan proceeds will prepay the development’s current mortgage, complete capital projects that are under way, and, for the first time, provide for additional new reserves for future capital needs and ongoing maintenance.

Located in the Baychester section of the Bronx, Co-op City is situated on 330 acres located along the west bank of the Hutchinson River. In addition to 35 residential structures, the site includes three shopping centers, a 25-acre educational park, eight parking garages, three elementary schools, two middle schools, a high school, a weather station, 14 gymnasiums, two swimming pools, 12 churches, six nursery schools and day care centers, four basketball courts, five baseball diamonds, numerous restaurants, and a power plant.

New York State’s Mitchell-Lama Housing Program was first proposed by state Sen. MacNeil Mitchell and Assemblyman Alfred Lama and was signed into law in 1955. The program provided for the creation of affordable housing, both rental and cooperatively owned, for middle-income residents. Developers received tax abatements and low-interest mortgages, subsidized by the federal, state, or New York City government. In total, 269 housing developments with 105,000 units were developed with state aid under the Mitchell-Lama program.