Wells Fargo & Co., the largest U.S. mortgage lender, will pay $39 million to promote homeownership and community development to address claims that it neglected bank-owned homes in minority communities.

The bank, in an agreement Thursday with the Department of Housing and Urban Development, will parcel out the aid to 45 communities and attempt to sell vacant properties to buyers who plan to live in them.

"Wells Fargo's investment demonstrates an ongoing commitment to stabilizing African-American and Hispanic neighborhoods in a way that advances equal housing opportunities," said Bryan Greene, a HUD deputy assistant secretary.

HUD opened an investigation last year after the National Fair Housing Alliance, a nonprofit advocacy organization, said San Francisco-based Wells Fargo violated the Fair Housing Act by allowing homes it owns in minority neighborhoods around the country to stay in a state of disrepair.

The NFHA said it reviewed 218 properties in eight cities, finding that those in white neighborhoods were better maintained and marketed than similar buildings in areas with large black and Hispanic populations.

"We appreciate the perspectives and collaboration of NFHA and HUD in helping us shape these initiatives, which are consistent with our long-standing commitment to homeownership, fair and responsible servicing, and investing in the communities we serve," J.K. Huey, Wells Fargo Home Mortgage senior vice president, said.