Bail was denied Thursday for a 29-year-old man accused of sexually assaulting a 12-year-old girl last month — and the alleged culprit was captured when the girl’s dad tricked him into coming over and then held him at knifepoint until cops arrived.

Danny Garay, of Portage Park, allegedly met the girl’s 19-year-old relative online using the video chat website Omegle, Cook County prosecutors said.

The 19-year-old invited Garay over to her home Aug. 6, where the two had sex in front of the 12-year-old, prosecutors said. Garay then asked the girl if she wanted to have sex and she said no. Garay, who knew the girl’s age, then assaulted her, prosecutors said.

The following day, Garay got a motel room and invited the 19-year-old and the 12-year-old over, prosecutors said. Garay and the woman again had sex in front of the girl and Garay then also allegedly assaulted the 12-year-old, despite her telling him to stop. During the assault, Garay told the girl to perform oral sex on the woman and she eventually did, prosecutors said.

Dad steps in

On Aug. 12, Garay allegedly texted the 12-year-old and said he wanted to have sex with her.

The girl’s father had her phone and texted Garay back telling him to come over. When Garay arrived at the home, the girl’s father held Garay at knifepoint until police arrived, prosecutors said.

The girl identified Garay in a photo array, and the 19-year-old admitted to detectives that Garay and the girl had had sex and that he knew the girl’s age, prosecutors said. The 19-year-old woman was identified as a witness in court and is not currently facing charges, prosecutors said.

Chicago police records show Garay was taken into custody Wednesday at his home and charged with two counts of predatory criminal sexual assault.

An assistant public defender for Garay said he works as a hairstylist and had no previous felony convictions.

Judge Charles Beach II ordered Garay held without bail and set his next hearing for Sept. 25.