Now, lawmakers are pushing for legislation to curb the practice.

“We were the only ones with a kid who was age-appropriate and that was just mean,” said Mr. Reilly, a personal trainer and actor who pays $1,250 a month for the studio apartment he shares with his wife and son. “But I’ve got stuff to do and a life to live, so I just laughed.”

New York City’s disparities in wealth have long played out in the city’s housing. It’s not uncommon for a luxury tower to rise within throwing distance of a low-income development. Mayor Bill de Blasio was elected on a platform that derided income inequality and the dwindling availability of affordable housing. His “tale of two cities” theme appears to also exist within buildings.

In recent years, developers who have earned tax credits by promising to provide affordable housing have built luxury condos with separate entrances and lobbies for the affordable rental units. The so-called “poor door” makes it easier to restrict who gets access to amenities. Last summer, 40 Riverside Boulevard, a luxury condo rising on the Upper West Side, drew criticism for a design in which low-income tenants enter through a separate door and do not share amenities with owners.

“The city has just begun to wake up and see that if we don’t act, this is going to be an increasing problem,” said Mark Levine, a member of the New York City Council who represents part of the Upper West Side. He is drafting legislation with Corey Johnson, another West Side council member, to expand the city’s anti-discrimination code to include rent-regulated tenants.

Last February, tenants gathered in the community room of Stonehenge Village, an Upper West Side rental complex, to hear about its new gym. Management explained that only market-rate tenants — fewer than 40 percent of the residents — would have access, said Jean Green Dorsey, the president of the tenant association.