The knife-wielding dad who allegedly hit his own child before flipping out on subway riders last month was arrested on Tuesday, cops said.

Edgar Rodriguez, 23, who could be seen on video terrorizing a car with a knife in hand on June 24, was apprehended by cops in the Manhattan Robbery Squad, according to police sources.

The victim of his tirade, who was on a northbound E train with his wife and child, told The Post that Rodriguez became enraged when other riders reacted to him striking his own kid.

“You just hit your son. I think it’s not necessary,” the victim said before Rodriguez pulled out a knife.

“He pulled a knife, ‘Come over here. I’m gonna kill you. I’m gonna kill you,'” the victim recalled.

Rodriguez was charged with endangering the welfare of a child, menacing and criminal possession of a weapon.