The man threatened passers-by, lit a fire and set off fireworks, police said, and was then detained. The authorities identified him as an Army veteran and said he had targeted immigration officials.