A federal judge ruled on Friday that the predominantly white Long Island village of Garden City had intentionally discriminated against blacks and Hispanics when it enacted a zoning change in 2004 that favored the building of townhouses or single-family homes over modestly priced apartments.

The lawsuit was supported by New York Communities for Change and MHANY Management Co., a nonprofit developer, after the original plaintiff, Acorn, was dissolved. It stemmed from a decision by the former Nassau County executive, Thomas R. Suozzi, to sell a 25-acre county-owned complex used for social services offices to a developer.

The village trustees initially proposed zoning the area for multifamily residential housing. But outcries at public hearings ensued, with some speakers warning that lower-income tenants would be drawn to more affordable apartments. The village changed the zoning so that most of the land could be used for either 90 single-family homes or up to 150 townhouses and 36 apartments.

Judge Arthur D. Spatt of Federal District Court in Central Islip, N.Y., concluded that “the plaintiffs have established by a preponderance of evidence” that “the village’s acts had both an adverse impact on minorities and tended to perpetuate segregation.” Less discriminatory alternatives for zoning could have been found, the judge said. He gave the plaintiffs 30 days to propose remedies that the village should take.