NEW YORK CITY- For decades, teachers, firefighters, and policemen have found refuge from New York City’s brutal housing market in Peter Cooper Village and Stuyvesant Town, one of the biggest communities ever built for people earning moderate incomes. But that refuge may soon be gone forever.

In October, more than 11,000 rental apartments at Peter Cooper Village and Stuyvesant Town were bought by investors who have been quite explicit about their plans to raise rents as quickly as the city’s rent stabilization rules will allow. The community sold for more than $490,000 per unit, a price that effectively commits the new owners to very high rents.

That transaction both signals the end of an era and exemplifies the pressures New York City will face over the next six years as it works to achieve its goal to build or preserve 165,000 units of affordable housing over the 10 years from 2004 to 2013.

That includes 22,000 new units of middle- and moderate-income housing the city aims to help finance through its new Middle Class Housing Initiative (MCHI).

The biggest obstacle to creating new affordable housing here is finding the land to build on. Once, it seemed like this city would never run out of burned-out buildings to give to affordable housing developers. At its peak, New York City owned nearly 10,000 buildings with 100,000 units of housing.

Now that portfolio is almost used up, and the city has to find new places to build. One is a 24-acre waterfront site on the East River in Queens. New York City will turn the waterfront land over to developers to create as many as 5,000 new moderate-income rental units. That would make the project the biggest thing built for middle-income people here since Starrett City opened its 5,888 apartments in Brooklyn in 1974.

The new apartments will become the latest phase of Queens West, which has already added hundreds of luxury apartments to the rusted waterfront of Long Island City in Queens. They will also make up nearly a quarter of the production envisioned under the MCHI.

The initiative’s 22,000 units will probably be financed with bonds issued by the city, such as 501(c)(3) tax-exempt bonds or tax-exempt private-activity bonds. The city is also working to update its existing suite of affordable housing programs to help finance middle-income housing. A few middle-income projects may include expensive luxury units to help pay for the cost of building more affordable apartments.

These middle-income apartments will be built on large sites throughout the five boroughs. To find these sites, the city is looking at parcels held by a dizzying variety of public agencies. Queens West, for example, will be built on land now held by the Port Authority of New York and New Jersey.

The land at Queens West will cost the city $146 million, including $100 million in cash plus promised infrastructure improvements, a bargain for waterfront land with skyline views. Developers will pay the city less than market value for the land, and in exchange, must set aside more than half the 5,000 new apartments for households earning no more than $60,000 per year for a family of four, or 80 percent of the area median income (AMI). The city is requiring that even the most expensive apartments be affordable to households earning up to $145,000 per year, or 195 percent of AMI.

The subsidy from the city will total more than $50,000 per unit for the new apartments. That’s less than half of what it would have cost to preserve Peter Cooper Village and Stuyvesant Town as middle-income housing, according to Rafael Cestero, commissioner of development for the city’s Department of Housing Preservation and Development (HPD). Also, the income restrictions on the new Queens West will continue for between 20 and 40 years.

Housing officials are also looking for land for new middle-income housing in the deep setbacks and underused parking lots of public housing projects. On the West Side of Manhattan, the city is now planning to build 435 new apartments targeted to middle class families on land owned by the New York City Housing Authority at public housing projects like Haborview, the Chelsea Elliott, and the Robert Fulton Houses.

“That land is out there,” said Cestero.

The city is also hurrying to finish building out the last of the land it has held for decades. Arverne, a crumbling neighborhood in Queens, used to be a prosperous beach resort on the Atlantic Ocean. But in 1964, the city took possession of 308 acres of ramshackle, oceanfront bungalows, intending to eventually redevelop the site. Instead, the parcels lay neglected for almost 40 years as officials and advocates discussed what to build and how to pay for the work.

The developers have just been picked for the last phase of work at Arverne, which will eventually create 4,100 units of moderate-income housing.

The boldest part of the city’s plan involves little public subsidy. Just across the poisonous Newtown Creek from Queens West, the redevelopment of the Williamsburg and Greenpoint neighborhoods of Brooklyn is roaring ahead. All the city had to do was change the zoning to allow tall, residential buildings on the waterfront.

That rezoning will make room for 10,800 units of future housing along a two-mile stretch of the Brooklyn waterfront. In exchange, developers that build there must set aside at least 20 percent of their units as permanently affordable rental housing.

The city’s strategy is to encourage the construction of new housing at all income levels to ease New York’s housing shortage, according to Shaun Donovan, commissioner of HPD.

Over the last 40 years, market-rate rental production in the outer boroughs of New York City has been slim. Builders finished a scant 1,000 units a year in the late 1990s. After 2001, that count shrank to just a few hundred a year, according to a tally of new, market-rate rental properties kept by Reis, Inc., a housing research firm based in Manhattan.

Even as building lagged, the city’s population grew, reaching a record 8.2 million in 2005, and it’s expected to soar to at least nine million in the 2020s.

That mismatch between housing and population growth is at the heart of the latest chapter in New York City’s housing crisis.

Officials like Donovan and Cestero plan to change the fundamental economics of the housing crisis by unleashing a flood of new development on neighborhoods where no new housing has been built in decades.

Even the production of new luxury apartments can help calm the bidding war for older apartments in gentrifying neighborhoods, if enough new apartments enter the market.

Builders asked for and received permits to build 23,106 units of housing of all types in the outer boroughs in 2005 alone, according to HPD. “I don’t know that you can foresee a time that the New York market is going to be overbuilt,” said Cestero. But if their aggressive building plans succeed, officials hope they will keep middle-income families from being priced out of the city.