A veteran Bronx police officer has been arrested after repeatedly threatening to kill his baby mama during a terrifying two-hour text-message tirade, authorities said yesterday.

Sgt. Mario Morales, 37, of The Bronx, allegedly lost it last week during a digital disagreement with the mother of his young son, telling her that she should “feel lucky I didn’t kill you.”

The 11-year cop’s other alleged texts included:

* “I’ve never felt hate towards someone like u.”

* “I don’t want to end up doing something crazy.”

* “The last thing I want to do is for my son to lose one of his parents.”

The texts were sent last Friday between 7:54 and 10:15 a.m., law-enforcement sources said.

Morales, of Patrol Borough Bronx, was arrested Friday night, charged with aggravated harassment in Queens Criminal Court and released on his own recognizance. He is scheduled to return to court on July 21.

The court also issued a temporary order of protection, ordering him to have no contact with his ex.