A man’s lifeless body was found rolled up inside a red carpet and dumped outside of a Starbucks in Harlem early Thursday, police said.

The gory discovery was made by a passerby who noticed two feet sticking out of the carpet on the sidewalk outside of the chain coffee joint at the corner of West 145th Street and Bradhurst Avenue just before 6 a.m., cops said.

The witness quickly called the police who found the unconscious and unresponsive man with signs of head trauma wrapped in a cardboard box inside of the carpet, authorities said.

Medics responded and the man – whose identity was not immediately known – was pronounced dead at the scene.

“We’re treating it at this point as a homicide,” NYPD Chief of Detectives Dermot Shea told reporters, adding that investigators have a possible ID on the man, “but it’s still way too preliminary to put that out.”

Shea pointed out that the man, who was clothed, had “some potential wounds to the head.”

The city’s Medical Examiner will determine the cause of death.

A red Target shopping cart was found on Bradhurst Avenue — around the corner from where the body was discovered — and marked as evidence by police.

Investigators believe the cart played a role in moving the body, according to a cop source.

The Starbucks closed for the day and employees hunkered down inside as authorities investigated the scene.

Neighborhood residents were stunned by the grisly find.

“This is some ‘Law & Order’ s–t,” Anike Rabiu, 45, said. “This is a fairly busy intersection…it sounds like somebody might have offed [him] somewhere and they had to get rid of it.”

One 55-year-old woman, who declined to give her name, said it felt like a return to the Bad Old Days.

“Back in the ’80s, bodies on our street, you’d see it…But in 2019? This is very strange.”