A man on trial for killing his girlfriend was shot to death inside a Stockton, Calif., courtroom Wednesday after he attacked the judge presiding over his murder trial with a cutting tool.

A Lodi police detective attending the trial fatally shot 28-year-old David Paradiso after he left the stand and began attacking San Joaquin County Superior Court Judge Cinda Fox, said Dave Conecny, a spokesman for the sheriff’s department.