A police officer in Northern California was justified when he shot and killed a 25-year-old man who had stabbed his ex-girlfriend and a police dog before throwing a knife at an officer, officials said in a report released Tuesday.

The Santa Clara County District Attorney's Office said in a 32-page report that Lt. Emmett Larkin shot and killed Jesus Contreras Jr. because he posed an "imminent threat."

“The law allows Lt. (Emmett) Larkin to fire his weapon in defense of others (and himself) until the suspect no longer posed an imminent threat," Assistant District Attorney Stacey Capps wrote in the report. "Lt. Larkin’s belief the suspect posed an imminent threat was clearly reasonable given the suspect’s words, stabbing of Jane Doe, assaultive actions toward the officers and the fact he had already stabbed the canine.”

FLORIDA POLICE OFFICERS CHARGED AFTER HOME SURVEILLANCE VIDEO SHOWS SERGEANT SLAPPING HANDCUFFED TEEN

The shooting came after officers responded to a report of a domestic-related stabbing on Oct. 31, 2017. Officers arrived to find a woman who had been stabbed in the stomach, according to the report.

"She told officers that Contreras had told her he would 'cut her to pieces,' stabbed her and barricaded himself in her home," the DA's report said. The woman also told officers that Contreras was on parole and did not want to go back to jail.

Contreras then barricaded himself in the home, and a police dog named Jax was sent in. Officials said that Contreras then stabbed Jax numerous times, who died later that night.

Officers then entered the home and tried to convince Contreras to surrender, but Contreras continued verbally challenging officers while refusing to give up.

GUNMAN BROKE INTO PHILADELPHIA HOME, FATALLY SHOT PIZZA DELIVERYMAN IN 'AMBUSH-STYLE ATTACK,' POLICE SAY

"Contreras, who continually refused to surrender and verbally challenged the officers, threw a knife at Lt. Larkin, striking him on his arm," the DA's office said. "The officer fired his weapon twice, striking Contreras once, mortally."

CLICK HERE FOR THE FOX NEWS APP

The shooting was captured on bodycams worn by officers. When police eventually got into the room where Contreras was held up, they discovered three other knives and one in his back pocket.

A toxicology report of Contreras's blood revealed the presence of methamphetamine, amphetamine and THC, according to officials.