WASHINGTON - Wells Fargo has agreed to spend at least $42 million to settle allegations that it neglected the maintenance and marketing of foreclosed homes in black and Latino neighborhoods across the country, the National Fair Housing Alliance announced Thursday.

A yearlong investigation by the advocacy group found that homes serviced by Wells Fargo in minority communities were far more likely than those in white areas to be left in disrepair, with broken windows, unkempt yards or water damage. These home were also less likely to have for-sale signs than ones in predominantly white neighborhoods.

Under the agreement, Wells Fargo, which did not admit any wrongdoing, will provide $27 million to nonprofit groups to promote homeownership, neighborhood stabilization and property rehabilitation in minority communities in 19 metropolitan areas. It will also provide $11.5 million to the Department of Housing and Urban Development to help 25 other cities, including Phoenix, the only Arizona city on either list.

The agreement addresses one of the lingering scars of the housing crisis. As the number of foreclosures climbed in the aftermath of the housing crash, lenders scrambled to offload foreclosed properties, with many piling up in minority neighborhoods where there was a high concentration of subprime loans. Communities have been eager to see these vacant properties sold because over time they can bring down property values and attract crime, consumer groups say.

The agreement, reached Wednesday, resolves an April 2012 complaint that the advocacy group filed with HUD. HUD did not rule on whether Wells Fargo violated any fair housing laws, but the agreement closes the case.

As part of the agreement, Wells Fargo agreed to give borrowers who plan to live in a home after the purchase priority in the bidding process over investors eager to snap up cheap houses to rent out or flip. Traditional buyers will get more time before investors, which has increasingly included Wall Street firms, are allowed to make an offer.