Doua Moua, 23, played a menacing gangster in a Clint Eastwood movie, but Mr. Moua swears he really is a nice, gentle and rules-abiding fellow. At least he was until he moved to New York City and unwittingly slipped into a world of lawlessness.

Mr. Moua lives with five roommates. And in New York, home to some of the nation’s highest rents and more than eight million people, many of them single, it is illegal for more than three unrelated people to live in an apartment or a house.

The law, for decades part of the city’s Housing Maintenance Code, is little known, widely broken and infrequently enforced. Three citations have been issued since July, according to the Department of Housing Preservation and Development.

When the law is enforced, it is usually because of a complaint from a neighbor or because inspectors spotted a violation while responding to a maintenance problem. The violation is rarely written up unless it is accompanied by a host of others. Rarer still are the tenants who call up the city to turn in their landlord.