The former Bronx student who got his teacher pregnant in 2012 has confessed to police that he killed the woman and their 4-year-old boy, police sources told The Post.

Cops charged 23-year-old Isaac Duran Infante with two counts of murder Tuesday after he admitted to the double slaying of ex-Dewitt Clinton High School teacher Felicia Barahona, 36, and their little boy, Miguel, inside her upper Manhattan apartment, law enforcement sources said.

Barahona was discovered with an electrical cord tied around her neck around 8:30 a.m. Monday in the living room of her third-floor apartment on West 153rd Street after the building superintendent smelled a foul odor emanating from the residence.

Miguel was found drowned and floating face down in the bathtub, sources said.

Infante described his actions as an evil deed during his confession, referencing the “devil,” sources said.

He also said that he killed Barahona and their child because he was angry over the way she was raising the boy, sources said. His gripes included how she would dress Miguel in girl’s clothing, sources said.

Infante also mentioned an issue with child support payments. He paid $80 and $100 in child support weekly, according to sources.

When initially contacted by investigators, Infante put up the front of a grieving father and said he hadn’t visited the apartment since 2011, sources said.

But police later found out that he lied to them after he was spotted on building surveillance footage several days ago entering the six-story building and leaving hours later wearing different clothes, sources said.

Infante, a Bethlehem, Pennsylvania, resident, was captured on surveillance going in and out of the building over the course of several days.

The dad was supposed to spend Christmas with Barahona, their son and Barahona’s mom at the mother’s house on West 56th Street, but he never showed, sources said.

Law enforcement sources said Duran had no criminal record or history of mental illness. He was employed by a company at an airport near the Pennsylvania-New Jersey border, sources said.

Barahona, an Afghanistan war vet, was in the news in 2013, when city school officials disclosed that she had been fired from her $73,000 teaching job for having a romantic fling with Duran, who was one of her 17-year-old students at Dewitt Clinton High School at the time.

She first struck up a relationship with the boy when he was 15, but waited two years until his 17th birthday to have intercourse. She told the teen “not to worry” about using protection during their five-times-a-week trysts, according to a report by the Special Commissioner of Investigation.

The illicit couple broke up in 2012 before Miguel was born. Oddly, Barahona dressed the new baby in pink and described him as a girl in Facebook photos from 2013.

She calls herself “divorced” on her Facebook page, which also features the tragic woman’s favorite quote: “Never give up!”

Barahona was taking forensic science classes at John Jay College and a classmate last saw her on Dec. 22 for a final exam.