A Union City man raped his niece multiple times over a five-year period in the home they shared, starting when she was just 4 years old, authorities said.

Gerardo Pena, 44, has been charged with aggravated sexual assault and endangering the welfare of a child. He is being held at Hudson County jail in Kearny until his trial, a judge ruled in a detention hearing.

Authorities said Pena, who was arrested Nov. 5, is in the country illegally.

A criminal complaint said Pena was also charged with child endangerment of his own two children, girls 10 and 13 years old, who apparently found out that their father was raping their cousin. The complaint said Pena punched and choked his kids.

The girl’s five-year ordeal was reported to Union City police on Nov. 1, the criminal complaint said. Union City police then notified the Hudson County Prosecutor’s Office’s Special Victims Unit.

One of the victim’s cousins noticed her dad was taking the 9-year-old into a room alone on multiple occasions. On at least one occasion, Pena said he was taking the girl into the room “to teach her,” the complaint said.

The victim told her cousin that Pena “does bad things to her when he brings her in the other room,” the criminal complaint said.

The sexual assaults occurred when the victim’s mother and aunt went shopping, the victim and her cousin both said, according to the complaint. The assaults also included the girl being kicked and her ears pulled by Pena.

The sex assaults started when she was 4 years old and continued into fourth grade, the complaint said.