Updated

A group of San Francisco police officers were accused Thursday of exchanging offensive text messages that emerged during an investigation into allegations of sexual assault by an off-duty officer last year, police and prosecutors said today.

The racist and homophobic missives come as the SFPD has had to battle allegations of systemic racism within its ranks, including a separate scandal last year in which 14 other officers were accused of sending racist text messages.

The new accusations are related to the criminal investigation of alleged sexual assault by Officer Jason Lai while off-duty in August 2015, police said.

District Attorney George Gascon said investigators were sifting through evidence sent by the Police Department late last year related to Lai's case, including 25,000 pages of text messages, and discovered the messages sent by at least four officers.

The district attorney said the messages included uses of the n-word, "disparaging comments about Hispanics", and speculation about the sexuality of female officers. 

Gascon called the messages "very problematic" and said they included texts from the time when the previous text message scandal was revealed in March 2015.

In the earlier case, a judge in December ruled against the Police Department being able to fire officers who exchanged the racist text messages, saying the department failed to act within a one-year statute of limitations after being notified by federal prosecutors of the texts.

Gascon said the text messages uncovered recently "clearly acknowledged" the earlier scandal and the officers were "almost mocking what was going on."

Gascon said once he learned of the new messages, he immediately sent a letter to police Chief Greg Suhr to make sure the officers weren't on active duty with the public.

Gascon claimed today his office was not notified of the bigoted text messages by police and only learned of it late last week after sifting through the thousands of pages of messages themselves.

"It was never pointed out to us," Gascon said.

"If the department knew about it, it's a problem that we weren't told," he said.

In response, Suhr wrote Thursday that the district attorney's office was sent evidence including the text messages on Sept. 21, and that police notified his office on multiple occasions in September, October, November and January of the existence of the texts.

"For you to suggest that you discovered the text messages through your own criminal investigation would be disingenuous," Suhr wrote. "This is not new information as our offices have been working closely on this case with at least three members of your staff to ensure the fair administration of justice."

Police said that during the criminal investigation into Lai's case, the department's internal affairs investigators learned on Aug. 8 that officers had sent the messages.

The department acted immediately to suspend the officers and referred the matter to the city's Police Commission for review, police said.

Since then, two of the officers have separated from the department. A third officer has an open case pending with the Police Commission and could face discipline or termination, police said.

Lai was charged last week with misdemeanor counts of unlawful possession of criminal offender history information and misuse of confidential Department of Motor Vehicle information, but prosecutors found insufficient evidence to charge him with sexual assault. He has been on unpaid leave since the investigation began, police said.

City Public Defender Jeff Adachi said his office would "begin a full review of past cases that may have been tainted by these officers," Adachi said. "I am also calling for an independent investigation into when the police chief and district attorney learned of the text messages."

"Every person in San Francisco deserves equal justice," Adachi added. "It does them a grave disservice to dismiss every hateful act as an isolated incident. The Police Department must address the culture that lets racism fester in its ranks."

Click for more from KTVU.com.