Bank of America Corp.'s Countrywide Financial unit will pay a record $335 million fine to settle civil charges that it discriminated against minority homebuyers. It is the largest residential fair-lending settlement in U.S. history, and a winning result for President Barack Obama's administration, which aggresively tackled the issue.

Countrywide Financial was charged with discriminating against black and Hispanic borrowers during the housing bubble. The practice occurred before Bank of America (NSYE: BAC) owned the financial company.

The department's actions against Countrywide makes clear that we will not hesitate to hold financial institutions accountable, including one of the nation's largest, for discrimination, Attorney General Eric H. Holder Jr. said in a statement. These institutions should make judgments based on applicants' creditworthiness, not on the color of their skin.

Investigation had revealed that Countrywide had charged higher fees and rates for more than 200,0000 minority borrowers from 2004-2008, in the midst of the housing boom. Some 10,000 borrowers were also pushed in to sub-prime mortgages when others with similar qualifications got standard mortgages.

Bank of America noted upon the settlement that the problems with Countrywide occurred before B of A acquired the financial company.

We are committed to fair and equal treatment of all our customers, and will continue to focus on doing what's right for our customers, clients and communities, said Dan Frahm, Bank of America spokesman, in a statement. We discontinued Countrywide products and practices that were not in keeping with our commitment and will continue to resolve and put behind us the remaining Countrywide issues.

Countrywide's practices impacted some 200,000 African-American and Hispanic borrowers in 41 states in all, the Justice Department said.

The victims had no idea they were being victimized. They were thrilled to have gotten a loan and realize the American dream, Thomas Perez, head of the Justice Department's civil rights division, told reporters, according to Reuters. This is discrimination with a smile.

Bank of America's stock was up 1.16 percent on the news Wednesday, or six cents, to $5.23. The stock has been trading near a 52-week low of $4.92.