A California police officer involved in a controversial shooting last year has resigned after the discovery of racist text messages he wrote, including some making light of the shooting, a police chief says.

Mark McNamara, who joined the San Jose Police Department in 2017, quit last week after being notified of an investigation into his offensive messages, Police Chief Anthony Mata told the Bay Area News Group.

Mata said McNamara was being investigated by the department’s internal affairs unit for an unrelated and unspecified matter, and that led to the revelation that he "had sent disgusting text messages that demonstrated racial bias."

FBI ARRESTS CALIFORNIA POLICE OFFICERS IN CIVIL RIGHTS INVESTIGATION

CA Fox News graphic

In a text message dated the day after the shooting, McNamara appears to refer to Green with a racial slur. (Fox News)

HATE CRIMES IN CALIFORNIA INCREASED BY 20% LAST YEAR

A dossier of text messages show McNamara talking to two unnamed recipients and referring to the March 27, 2022, shooting of K’aun Green, according to the chief.

McNamara shot and wounded Green, who is Black, after Green appeared to have quelled a fight that broke out inside an eatery near San Jose State University. Green disarmed one of the people in the fight, and was backing out of the front door, holding a confiscated handgun in the air, when he was shot, according to police.

In a text message dated the day after the shooting, McNamara appears to refer to Green with a racial slur. Other messages from June 2023 appear to have been sent while McNamara was being interviewed by the City Attorney’s Office and Green’s legal team, which sued the city over the shooting.

CALIFORNIA UNIVERSITY OFFICE WILL NO LONGER USE THE WORD 'FIELD' OVER RACIST 'CONNOTATIONS'

Adanté Pointer, whose firm Lawyers for the People is representing Green, said the messages affirmed to him that the shooting of his client "was driven by racial animus."

Contact information for McNamara could not be found Sunday.

San Jose Police Officers’ Association President Steve Slack said the text message investigation "is a disconcerting reminder that not everyone has the moral compass necessary to be in the law enforcement profession … This behavior is beyond unacceptable, and we condemn it in the strongest possible terms."