Good Samaritans came to the rescue of a mother and her 3-year-old daughter who were attacked by a homeless man threatening to throw them off a fire escape in the Bronx Wednesday night, police said.

Christian Valdez, 28, who knew the 37-year-old woman from church, had asked to stay at her apartment on Caldwell Avenue, near East 149th Street, in Woodstock at about 7:30 p.m., police said. When she refused, he broke his way into her third-floor apartment, they said.

Valdez chased the woman and her daughter to the fire escape and struck the mother with a glass bottle. A struggle ensued, leaving the mother with a stab wound to the stomach and the daughter with a slash on her left arm, police said.

Valdez then grabbed the 3-year-old girl, and when the woman tried to take her daughter back, he threatened to throw her over the railing, an NYPD spokesman said.

Two Good Samaritans climbed the fire escape and managed to get the child from Valdez, police said. Both the mother and her daughter were taken to an area hospital to be treated for their injuries.

Valdez was arrested at the scene and taken to the hospital for a psychological evaluation, police said. He was charged with assault, burglary, acting in a manner injurious to a child and harassment.

The investigation is ongoing.