WASHINGTON — The Justice Department on Wednesday announced the largest residential fair-lending settlement in history, saying that Bank of America had agreed to pay $335 million to settle allegations that its Countrywide Financial unit discriminated against black and Hispanic borrowers during the housing boom.

A department investigation concluded that Countrywide loan officers and brokers charged higher fees and rates to more than 200,000 minority borrowers across the country than to white borrowers who posed the same credit risk. Countrywide also steered more than 10,000 minority borrowers into costly subprime mortgages when white borrowers with similar credit profiles received regular loans, it found.

Attorney General Eric H. Holder Jr. said the settlement showed that the Justice Department would “vigorously pursue those who would take advantage of certain Americans because of their race, national origin, gender or disability,” adding: “Such conduct undercuts the notion of a level playing field for all consumers. It betrays the promise of equal opportunity that is enshrined in our Constitution and our legal framework.”

The settlement is subject to approval by a federal judge in California; according to the proposed consent order filed Wednesday, Countrywide denied all of the department’s allegations.