A homeless woman was raped Thursday by a man who walked up to her as she slept on the sidewalk near Harlem’s notorious 125th Street homeless encampment – the same hangout that the NYPD and Mayor de Blasio have been unable to clean up, police sources told The Post.

Surveillance video shows the man approaching the 22-year-old victim in front of 75 E. 125th St., between Madison and Park avenues at about 5 a.m. Thursday, pulling down his pants and having sex with her in plain view of people passing by.

“He’s having sex with her for a few minutes and it doesn’t appear she knows – she’s sleeping apparently out cold,” a source said.

The source said, “She was motionless, laying on the sidewalk. She woke up to him having sex with her. Then you see him pulling up his pants.”

The victim told cops that afterwards the two had a brief conversation and a smoke. The man, described as in his 20s who was wearing a dark baseball cap and T-shirt, with white baggy pants, offered her a cigarette. She took the cigarette and then he walked away.

The woman then got up and walked to a nearby police precinct to report the rape.

“This is right near where they’re having that big initiative,” the source said, referring to the homeless encampment.

“The mayor is saying there’s not a homeless problem, but there are literally people stretched out on the street there. In the middle of the rape, another homeless man walks to within about 15 feet of them and goes to sleep himself.”

De Blasio’s administration has recently tried to break up the litter-strewn encampment as part of a city-wide crackdown targeting 80-plus trouble spots throughout the city.

It’s unclear if the attacker was also homeless. He was carrying a cell phone and wearing clean clothes, sources said.

Detectives are canvasing the area for surveillance video and witnesses.

Additional reporting by Natalie Musumeci