The Department of Justice said Wednesday that Bank of America will pay $335 million over accusations that its Countrywide subsidiary had engaged in discriminatory lending practices.

Countrywide, which Bank of America bought in 2008, is accused of discriminating against more than 200,000 black and Hispanic borrowers during the mortgage boom preceding the financial meltdown.

These borrowers were charged higher lending fees and interest rates than their credit profiles warranted, the Justice Department said. Thousands of black and Hispanic borrowers were also given subprime mortgages, even though whites with similar credit histories received prime loans.

The Justice Department said the $335 million deal Countrywide will pay is the largest residential fair lending settlement in history. The alleged misconduct from Countrywide occurred from 2004 to 2008.

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

Bank of America spokesman Dan Frahm stressed that Countrywide's business practices before the Bank of America merger are at issue.

"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," he said. "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."

According to the Justice Department, Countrywide allowed loan officers and mortgage brokers to alter a loan's interest rate and fees after the price was set based on the borrower's credit history. Such discretion opened the door to race-based discrimination, according to the department.

African-American and Hispanic borrowers were also slammed with higher fees because they were placed in subprime mortgages, which come with adjustable interest rates that suddenly increase after several years, according to the complaint.

"Once those borrowers walked in Countrywide's door, they did not receive fair and equal terms, they received discriminatory terms," said Thomas E. Perez, assistant attorney general in the Civil Rights Division. "And chances are, the victims had no idea they were being victimized. They were thrilled to have gotten a loan and realized the American dream."