BOSTON (AP) — The city of Boston has paid $2.6 million to several Black police officers to settle a longstanding federal discrimination lawsuit over a hair test used to identify drug use, lawyers for the officers said Thursday.

The city eliminated the test in 2021 and has now paid damages to three Black officers and a cadet who lost their jobs or were disciplined as a result of the test, their attorneys said in a news release.

The case file noted that a settlement had been reached, but the details had not been filed yet. Messages seeking comment were left with the Boston Police Department and the lead attorney representing them.

The officers sued the city in 2005, claiming its hair test is discriminatory because black people’s hair is more susceptible to false positives. The city and the company that performed testing for Boston police rejected any suggestion that the tests are racially biased.

The case was twice considered by the First Circuit Court of Appeals. In 2014, the court agreed that the hair test fell disproportionately on Black officers. Two years later, the court found evidence sufficient to show that the city had continued to use the hair test even after having been informed of a less discriminatory alternative.

The case went to trial in 2018, and the parties subsequently entered into mediation, resulting in the settlement.

“This settlement puts an end to a long, ugly chapter in Boston’s history,” said Oren Sellstrom of Lawyers for Civil Rights, a nonprofit that has represented the officers. “As a result of this flawed test, our clients’ lives and careers were completely derailed. The city has finally compensated them for this grave injustice.”

Boston Mayor Michelle Wu, who took office at the end of 2021, said in a statement that the “settlement marks the end to an important process to guarantee that every officer is treated fairly.”

“Under Commissioner Cox’s leadership, we are strengthening our entire department by building more trust within the department and with community, and supporting a workforce that reflects the communities we serve,” Wu said.

The Massachusetts Association of Minority Law Enforcement Officers also was a plaintiff.

"The city is still trying to make up for the loss of diversity on the police force that resulted from use of the hair test,” Jeffrey Lopes, association president, said in a statement.

GBH News’ Rachel Armany contributed reporting.