A New York City man accused of groping a 6-year-old boy during the child’s birthday party died Thursday morning after he tried to escape his accusers and fell out of a fourth-story window, police said.

Edgar Collaguazo, 44, had been locked in a room at his Queens apartment after furious parents called police, the New York Daily News reported.

“If he didn’t have a filthy mind, (he’d) simply stay and face the situation,” the mother of the boy told the Daily News.

Collaguazo’s death capped what began as a joyous celebration at his apartment. The boy lived with his parents in a rented room inside Collaguazo’s place.

The party was in full swing when Collaguazo returned home sometime Wednesday evening, the boy’s mother said.

Collaguazo allegedly invited at least three children — including the 6-year-old, his 5-year-old female cousin and another boy — into his room to watch a movie.

“The little girl was happy and well, and then suddenly, she came out, but ... she looked different,” the birthday boy’s mother told the Daily News.

The boy’s father peeked into the bedroom and saw no signs of any problems. But when the little girl’s mother looked into the room sometime later, she said she saw Collaguazo allegedly holding the boy on his lap, with his hand on the boy’s privates.

The mother rushed out of the room shrieking, the victim’s mother said.

“She came to me frightened and crying,” the boy’s mom said. “We never thought the man had a mind this dirty.”

Chaos broke out in the apartment as the fathers started beating up Collaguazo.

“I told them, ‘Stop beating him, already! I have called the police,’” the victim’s mother told the Daily News.

The relatives decided to lock Collaguazo in a room while waiting for the police to arrive. When they opened the door shortly afterward, Collaguazo was gone. Only when they looked out the window did they realize that Collaguazo had fallen to his death, the boy’s mother said.

A witness said he was leaving a friend’s house across the street when he saw a man trying to hoist himself over the security bars.

“The guy had one foot on the ledge trying to climb over the bars,” Jose Valentine said. “He let himself go head first and landed with a thud … It sounded like a pumpkin fell off the roof.”

A surveillance video obtained by the Daily News shows Collaguazo landing belly first onto an iron gate. His lifeless body then flops to the ground seconds before a police car pulls up.

Collaguazo, who has five prior arrests, was rushed to Elmhurst Hospital but doctors could not save him.