The New York Police Department said on the afternoon of Oct. 24, Ramirez allegedly approached the child from behind and then put his arms forcibly around her mouth, restraining her movements, then shoved his hand down her pants onto her vagina.

The victim began screaming, prompting Ramirez to run away, police said. The child was taken to a hospital where she was treated and released.

Ramirez was later identified as a suspect in the attempted rape thanks to a Crime Stoppers tip, police sources said.

Ramirez allegedly told the special victims’ squad he was in the area during the time of the rape happened but didn’t remember it because he smoked K2 and fell asleep, according to sources.

Police said Ramirez wasn’t charged initially because the victim didn’t recognize him; however, he was taken to a hospital for psych evaluation where he eventually made a full confession to police and prosecutors.

Police sources said officers found the clothes he was wearing on the night of the incident that had been stashed away.

Prior to his capture, surveillance video and a sketch was released to help assist in making an arrest in this case.