(KRON) — A man accused of beheading his ex-girlfriend with a samurai sword in San Carlos appeared in a San Mateo County courtroom Thursday.

Jose “Rafa” Rafael Solano Landaeta, 33, of Hayward, is charged with murdering Karina Castro outside her San Carlos home on September 8, 2022.

On Thursday, Landaeta pleaded not guilty by reason of insanity. Following the plea, Judge Michael Wendler appointed two doctors to prepare NGI (not guilty by reason of insanity) reports, and the defendant waived his right to a speedy trial.

The insanity plea means his defense attorneys will have to prove Landaeta was mentally insane at the time of the sword slaying, he did not understand the nature of the homicide, and he was unaware that the crime was morally wrong.

Jose Rafael Solano Landaeta glances around a courtroom on March 1, 2023 in Redwood City. (Pool photo / File)

Earlier this year, Judge Wendler ruled Landaeta is competent to stand trial based off psychological evaluations completed by Dr. Jeffrey Gould and Dr. Stephanie Young.

Castro was a mother of two, including an 18-month-old baby fathered by Landaeta when they were dating. Prosecutors said Landaeta and 27-year-old Castro were arguing over custody of their baby before he attacked her with a samurai sword at 363 Laurel Avenue.

“The defendant attacked the victim with a samurai sword, slashing in numerous times. Defendant attacked the victim in front of multiple witnesses walking on the street, and then walked away. He put the bloody sword in his car, which was parked two blocks away,” prosecutors wrote.

Jose Rafael Solano Landaeta is seen in handcuffs and jail inmate clothing as he listens in a courtroom on March 1, 2023. (Pool photo / File)

San Mateo County Sheriff’s deputies arrested Landaeta when he returned to the grisly homicide scene. Investigators said they found threatening Instagram messages sent by Landaeta to his ex-girlfriend in the days leading up to the attack.

Prosecutors outlined enough evidence at a preliminary hearing for the case to move forward to a trial.

Landaeta, who has a history of mental health problems, is being held in jail with no bail. His next court appearance is scheduled for July 27 at 8:30 a.m. when the judge will receive the NGI reports.

Castro is survived by her two young daughters, ages seven and one.