By Marty Graham

SAN DIEGO (Reuters) - A San Diego man charged with impaling five street people with railroad spikes, killing three of them, was declared on Monday to be mentally fit for trial in a crime spree that terrorized the homeless community of California's second-largest city last summer.

Jon David Guerrero, 40, who has a history of mental illness and lived in "supportive housing" for homeless and individuals with special needs before his arrest, is expected to enter a plea to charges of murder, attempted murder and arson when he returns to court next month.

During a brief hearing in Diego County Superior Court, defense lawyers accepted the finding of doctors treating Guerrero that he been restored to mental competency, meaning he is capable of understanding the charges against him and assisting in his own defense.

Judge David Danielsen agreed, officially declared Guerrero fit for trial and ordered him to return to court on April 4 for arraignment.

Guerrero, dressed in green jail garb and shackled at the wrists, appeared subdued and stood expressionless in a small glass-enclosed chamber within the courtroom. He said nothing during the proceedings except to answer "yes" when the judge asked if he understood he was consenting to waiving the customary 72-hour deadline for arraignment.

The ruling, following two court-ordered psychiatric evaluations, does not preclude Guerrero's attorneys from later mounting an insanity defense - an attempt to prove the accused did not understand the difference between right and wrong at the time a crime was committed, public defender Dan Tendon said.

Guerrero is charged in five attacks over 12 days last July in which he is accused of driving railroad spikes into the heads of his victims, and setting two of them on fire. The body of the first victim was also found impaled in the chest. The two survivors told police they were attacked as they slept.

All the victims were homeless men living on the streets or in vacant lots around San Diego. Authorities have not offered a possible motive for the attacks.

Guerrero was previously convicted of robbery and had been sent to a state psychiatric hospital at least once in the past, according to prosecutors. Court records show five prior mental health matters filed under his name since 2008, all under seal.

If convicted of the charges against him, Guerrero would face a maximum penalty of life prison, unless prosecutors were to choose to seek the death penalty.

(Writing and additional reporting by Steve Gorman; Editing by James Dalgleish)