SunTrust Mortgage has agreed to pay $21 million to settle a federal lawsuit alleging racial discrimination in its lending practices against Hispanics and African Americans.

This is the second-largest fair lending settlement ever obtained by the U.S. Department of Justice.

A complaint filed by the department in U.S. District Court in Richmond said SunTrust Mortgage charged more than 20,000 black and Hispanic borrowers more than similarly qualified non-Hispanic white borrowers between 2005 and 2009.

Minority borrowers in 75 geographic markets stretching from Virginia Beach to San Francisco paid more in loan fees or higher interest rates based solely on race or national origin, according to the complaint.

Assistant U.S. Attorney General Thomas Perez, head of the department’s civil rights division, said the discrimination was the result of SunTrust giving loan officers and brokers too much leeway to alter prices without regard to the actual risk that borrowers posed to the bank.

“This subjective and unguided discretion resulted in African-American and Latino borrowers paying more than similar qualified white borrowers,” Mr. Perez said. Minorities, he said, “paid what amounted to a racial surtax.”

The settlement was filed in conjunction with a complaint accusing SunTrust Mortgage of violating the Fair Housing Act and Equal Credit Opportunity Act by charging more than 20,000 black and Hispanic borrowers higher fees and interest rates than white borrowers -- not based on borrower risk, but because of their race or national origin.

T he Justice Department's investigation into SunTrust Mortgage began in December 2009 after a referral by the Board of Governors of the Federal Reserve to the Justice Department's Civil Rights Division for potential patterns or practices of discrimination.