SAN DIEGO -- A man with a criminal record and history of mental illness pleaded guilty on Monday to four counts of murder in a string of deadly attacks on sleeping homeless men in San Diego, two of whom were set on fire.

Jon David Guerrero, 42, agreed to be sentenced May 1 to four consecutive life terms in prison without the possibility of parole and an additional 143 years to life in prison, the Union-Tribune reported.

Guerrero also pleaded guilty to four counts of attempted murder, five counts of assault with a deadly weapon and two counts of arson for setting fire to two of four victims who died. The charges involved 12 men and one woman who were targeted over six months in 2016, the newspaper said.

Court records show Guerrero is diagnosed with schizophrenia and has a history of arrests and mental competency hearings, including one judge's order that sent him to a state hospital for treatment.

The only clue to a motive for the assaults came from Guerrero's first victim, who survived a knifing and asked his attacker, "Why did you do this to me?"

"Because you're a bum," Guerrero replied, according to the victim's statements cited by the Union-Tribune.

One assault victim who survived, Michael Papadelis, attended the Monday hearing and afterward said, "I think he did the right thing," by pleading guilty.

"I've been homeless. I know there are a lot of mentally ill on the streets. I don't hate Jon," Papadelis, 58, told the newspaper.

In 2018, Guerrero was declared mentally competent -- meaning he could understand the charges filed against him and assist in his defence -- and the criminal case against him went forward.