An Army veteran with a long-simmering hatred of black men claimed responsibility on Wednesday for using a sword to fatally stab a homeless man in Manhattan this week, the police said, calling the attack random and racially motivated.

The suspect, James Harris Jackson, 28, of Baltimore, surrendered to the police shortly after midnight on Wednesday, a day after the victim, Timothy Caughman, 66, stumbled into a police station bleeding from stab wounds to his chest and back, Assistant Chief William Aubry, the commander of Manhattan South detectives, told reporters at Police Headquarters. The police arrested him on a charge of second-degree murder, but the chief said they wanted to upgrade the charge by classifying it a hate crime.

“I’m the person you’re looking for,” Chief Aubry said Mr. Jackson told police officers when he walked into the police substation in Times Square. He had recognized himself in an image from a security camera broadcast on the news Tuesday evening, the chief said.

Mr. Jackson told the police that he had chosen New York City to make a statement by attacking black men. He told investigators where he discarded the murder weapon, a 26-inch sword with an 18-inch blade, and told them he was carrying knives in his pocket. Chief Aubry said the police had collected video evidence that seemed to corroborate Mr. Jackson’s account of the evening.