A brave 13-year-old fatally stabbed his mother’s ex-boyfriend yesterday when the jealous man barged into their home carrying a gun, Suffolk County cops said.

The boy — who will not be charged — plunged a knife into career crook Norman Shields, 48, after the thug entered the home of Natasha Bivins, 31, to confront another man she had been dating, cops said.

Shields stormed in the Mastic Beach home at 4 a.m. and began assaulting the woman, cops said.

Her son then took a large knife from the kitchen and stabbed Shields several times in his side, cops said.

Police said Bivins’s frightened new boyfriend fled, the kid remained.

Formerly of Brooklyn, Shields was taken to Brookhaven Memorial Hospital, where he died.

He had a lengthy rap sheet, dating back to 1981, that included drug and assault charges.