He hated black men. He wanted to kill one, and he did.

In a videotaped confession, James Harris Jackson, a white Army veteran from Baltimore, told investigators that he spent several days two years ago stalking black men in Manhattan before he spotted a 66-year-old man sifting through trash for recyclables.

And in an undeniable testament of his hate, Mr. Jackson said he pulled a short sword from his coat and repeatedly stabbed the man, Timothy Caughman.

The killing, Mr. Jackson said, was “practice” for a larger attack he had planned for Times Square where he intended to murder young black men who were with white women because he loathed interracial dating.

Mr. Jackson, 30, pleaded guilty on Wednesday to rare state charges of murder as terrorism and murder as a hate crime, accepting what is certain to be a sentence of life in prison without the possibility of parole. His dramatic plea to all counts against him came four months after the video of his interview with police was presented at a pretrial hearing in State Supreme Court in Manhattan.