Alleged school shooter Nikolas Cruz threatened to kill his ex girlfriend — and was expelled after fighting with her new boyfriend, classmates revealed Thursday.

“The reason he got expelled was because he was fighting with his ex-girlfriend’s new boyfriend,” Connor Dietrich, 17, a junior at Florida’s Marjory Stoneman Douglas High School, told The Post.

“He stalked her and threatened her. He was like, ‘I’m going to kill you,’ and he would say awful things to her and harass her to the point I would walk her to the bus just to make sure she was OK. We all made sure she was never alone.”

Cruz returned to the campus Wednesday with an AR-15 rifle and slaughtered 17 people.

Broward County Sheriff Scott Israel said at a press conference Thursday that Cruz had been expelled from the school for unspecified “disciplinary reasons” and was transferred to a different school in the county.

A math teacher at Marjory Stoneman Douglas had previously said he was kicked out for “threatening students” and teachers had been warned that he was not allowed on campus with a backpack.

Dietrich said Cruz was known for threatening other students and was fanatical about guns.

“He was just a very sketchy kid in general. Seeing him around the hallway I would try to keep my distance from him… he doesn’t look like someone I’d want to hang out with,” Dietrich explained to The Post.

“He wears [pro-America] stuff like that a lot, he was in JROTC so I guess he was pro-military but he was mostly pro-gun and everything. He had this obsession with guns.”

Sophia Serino, 17, said Cruz just “snapped” when he decided to open fire on his classmates and murder anyone in his path.

“There was a lot going on with him mentally. His mother died three months ago and… his other family members took [his inheritance] from him and kicked him out so he snapped,” Serino told The Post.

Reports have come out indicating Cruz suffered from autism.

“He’s been saying this stuff many times… During freshman year around he was in the bathroom and he was actually about to snap and plan this out and do it but [my friend] talked him down.

“It wasn’t something that was spontaneous. I think he really planned this.”