The Fresno Police Department identified the suspect who was shot and killed by a detective after breaking into his office and allegedly assaulting him on Tuesday as Joseph Roy, a 24-year-old man who was in court just that morning on charges of assault with a deadly weapon and assault by means likely to produce great bodily injury. 

Roy allegedly used a "sharp object" and slashed at the detective, who then used his service weapon to shoot and kill Roy. 

The 24-year-old had pleaded guilty to assault by means likely to produce great bodily injury in a separate case and was set to be sentenced on Tuesday morning, but the hearing was delayed until April 12, a spokesperson for the district attorney's office said. In that case, Roy attacked a man with a "blunt object" on June 17, 2021, according to the charging document. 

Joseph Roy

Joseph Roy, 24, was shot and killed after attacking a Fresno Police Department detective on Tuesday, according to authorities.  (Fresno Police Department)

After the hearing at the Fresno County Courthouse on Tuesday morning, Roy made his way to the Fresno Police Department's annex headquarters about a block away and broke in shortly before noon, according to police. 

THREE BUFFALO POLICE OFFICERS SHOT DURING PURSUIT, SUSPECTS IN CUSTODY

"During the assault, Mr. Roy Grabbed some sort of a sharp object and began stabbing and slashing the side of the detective’s head and neck with it," Lieutenant Bill Dooley said Wednesday. 

"Our detective grabbed his service weapon, fired, and ended the assault." 

Fresno

Roy allegedly broke into the Fresno City Hall Annex, which the police department uses as a headquarters, after his court date on Tuesday.  (Google Maps)

The detective, a 24-year veteran of the force who has not been identified, sustained lacerations to his head and neck area. 

CHICAGO POLICE OFFICER SHOT, ANOTHER PINNED BETWEEN VEHICLES DURING TRAFFIC STOP; SUSPECT IN CUSTODY

He was transported to a local hospital for treatment and is now at home recovering with his family, Dooley said. 

CLICK HERE TO GET THE FOX NEWS APP

Aside from the June 2021 assault, Roy was also arrested in 2018 on felony charges but was never convicted. The Fresno Police Department had contact with him two other times in recent years in which he was placed under a mental health hold. 

"We still do not know why he did this. We have not established what motivated him to specifically target the Fresno Department, specifically target our annex, and specifically target that detective," Dooley said. "As far as we can tell, this was a random attack on our detective."

Roy's court-appointed attorney declined to comment on Wednesday.