A man described as being mentally ill was arrested in California after police said he was found naked and carrying a sword and a loaded assault rifle.

No one was injured in the New Year's Day incident in San Jose that police spokesman Albert Morales said "could have gone really, really bad," the San Jose Mercury News reported.

Some 32 officers descended on the scene where police negotiated with the man, Coco Bennett, 29, for about two hours Tuesday morning.

Morales said Bennett repeatedly yelled, "You're going to have to kill me."

Police were able to retrieve the rifle and after police used a flash-bang device to distract the suspect, Morales said Bennett ran away.

He jumped a fence, hitting his head and dropping the sword. Police grabbed the sword and arrested Bennett.