The New York City government has brokered a settlement with fair housing advocates in an 8-year-old case involving proposed housing developments in Brooklyn that a judge said favored white and Hasidic residents over blacks and Hispanics.

As part of the settlement, which concerns the controversial development of low-income housing on five lots at the Broadway Triangle section of Brooklyn, the city would enter into a three-year, $2.4 million contract with Brooklyn Legal Services Corp. A to provide legal services to residents in the Broadway Triangle area and cut a $1.3 million check for attorney fees to Emery Celli Brinckerhoff & Abady, which will be split up among the plaintiffs attorneys.

The settlement awaits approval by Manhattan Supreme Court Justice Shlomo Hagler. If the settlement is approved, the city agrees that all housing built at the Broadway Triangle, which lies at the confluence of the Williamsburg, Bushwick and Bedford-Stuyvesant sections of Brooklyn, will be permanently affordable, which could result in more than 375 new affordable units.

The Broadway Triangle Community Coalition, an alliance of more than 40 advocacy groups and residents, filed suit in 2009 during Mayor Michael Bloomberg’s time in office, following a zoning and housing proposal for the site that would have given preference to residents Community District 1, a predominantly white jurisdiction that encomapsses the site, and no preference to residents of the nearby Community District 3, of whom 55 percent are black and 19 percent are Hispanic.

In 2012, Manhattan Supreme Court Justice Emily Goodman issued a preliminary injunction to halt the city’s plans, saying they would perpetuate segregation.

In a statement, Diane Houk, of counsel to Emery Celli, said the plan outlined in the settlement could provide a template to other neighborhoods facing “racially discriminatory housing redevelopment plans.”

The legal team for the plaintiffs also included Emery Celli partner Zoe Salzman; Martin Needelman and Shekar Krishnan of Brooklyn Legal Services Corp. A; and Arthur Eisenberg of the New York Civil Liberties Union.

Assistant Corporation Counsels Sheryl Neufeld, Louise Moed and Ave Maria Brennan appeared for the city.

The city is “pleased” with the outcome in the case, said Nicholas Paolucci, a spokesman for the city’s Law Department, in an emailed statement.

“The city’s priority has been to get the most affordable housing possible in this neighborhood, and to put this longstanding litigation behind us so this community can focus on the future,” Paolucci said.