A man who turned himself in to police early Wednesday morning in connection to the fatal stabbing of a 66-year-old man in midtown came to New York City with the intention of hurting black men, police said.

James Harris Jackson, 28, of Baltimore, walked into the NYPD’s Times Square substation about 12:25 a.m. and told officers, “I’m the person you’re looking for,” and that he had knives in his pocket, Chief of Manhattan Detectives William Aubry said during an afternoon news conference. Police recovered two knives from Jackson, Aubry said, including a 26-inch mini sword.

The victim, identified by police as Timothy Caughman, was stabbed in the chest and back on Ninth Avenue and West 36th Street about 11:15 p.m. Monday, police said. He then walked into the Midtown South Precinct on West 35th Street, asking for help. He was taken to Bellevue Hospital Center where he later died.

Jackson had arrived in the city on a Bolt bus from Maryland on Friday, Aubry said, and stayed at a midtown hotel over the weekend before wandering about on Monday.

Caughman had been going through garbage on the sidewalk when Jackson attacked, Aubry said. It appears he was randomly targeted.

“It is believed that the attack on Timothy Caughman was...racially motivated,” Aubry said, adding that Jackson has been harboring “feelings of hate against male blacks” for over 10 years.

Detectives from Baltimore are also working on the case and investigators are taking a look at his social media accounts, though Aubry said Jackson was “very forthcoming” with police about his motives.

“There [are] a lot of things going on behind the scenes that we’re trying to link together with him,” he said. “In general, he came here to target male blacks...He knew what he was doing when he came up here.”

In a statement released Wednesday, Mayor Bill de Blasio called Caughman an “innocent man” and said Jackson is now where he belongs: behind bars.

“More than an unspeakable human tragedy, this is an assault on what makes this the greatest city in the world: our inclusiveness and our diversity,” the statement said, in part. “Now it’s our collective responsibility to speak clearly and forcefully in the face of intolerance and violence – here or across the country.”

Aubry said Jackson purposely chose New York City for the attack because “it’s the media capital of the world and he wanted to make a statement.”

Aubry said it is not believed that Jackson attacked anyone else.

Jackson, who served with the U.S. military in Afghanistan, is now facing murder charges. Police are working with the Manhattan district attorney’s office to possibly upgrade those charges, according to Aubry.

A little after 3 p.m. on Wednesday, a cop shouted “heads up!” and officers walked a bewildered looking Jackson -- clad in a white jumpsuit and slippers -- out of the Midtown South Precinct and tucked him into the back seat of a silver Ford with blackened windows.

Police had released the surveillance footage of the suspect Tuesday night, just hours before Jackson turned himself in.

With Lauren Cook and Sheila Anne Feeney