A 21-year-old homeless man was charged Tuesday with the attempted rape an 8-year-old girl in the Bronx last month, police said.

Justin Ramirez was charged with several offenses, including multiple counts of sex abuse, forcible touching, and endangering the welfare of a child, according to the criminal complaint. 

He was being held in lieu of $75,000 bail following his arraignment on Tuesday.

An attorney for Ramirez did not immediately respond to a request for comment.

The girl was walking into her University Heights apartment building in the Bronx at about 5:40 p.m. on Oct. 24 when she was ambushed from behind, police said. Ramirez allegedly put his arms around her mouth and put his hand down the front of her pants.

“I waited for the little girl,” Ramirez allegedly told investigators, according to the criminal complaint. “I grabbed her from behind and placed my hand down her pants and placed my hand on top of her [expletive].”

The girl started screaming and Ramirez ran, police said. 

His next court appearance is scheduled for Jan. 6.