The suspect in a deadly rampage at a Florida high school is a troubled teenager who posted disturbing material on social media before the shooting spree that killed at least 17 people, according to police.

The 19-year-old suspect, Nikolas Cruz, had been expelled from Marjory Stoneman Douglas High School for “disciplinary reasons”, said Broward County Sheriff Scott Israel.

Victoria Olvera, a 17-year-old junior, said Cruz was expelled last school year after a fight with his ex’s new boyfriend. She said Cruz had been abusive to his girlfriend.

READ MORE: Florida high school shooting: Gunman kills 17 in Valentine’s Day massacre

School officials said Cruz was attending another school in Broward County after his expulsion.

Broward County Mayor Beam Furr said Cruz had treatment at a mental health clinic for a while, but had not been to the clinic for more than a year.

“It wasn’t like there wasn’t concern for him,” Mr Furr said.

“We try to keep our eyes out on those kids who aren’t connected. Most teachers try to steer them toward some kind of connections. In this case, we didn’t find a way to connect with this kid,” he added.

Mr Israel said investigators are dissecting Cruz’s social media posts, adding: “Some of the things that have come to mind are very, very disturbing.”

Daniel Huerfano, a student who fled the attack, said he recognised Cruz from an Instagram photo in which Cruz posed with a gun in front of his face. He recalled Cruz as a shy student.

“He was that weird kid that you see … like a loner,” he added.

READ MORE: Florida school shooting: What we know so far

Dakota Mutchler, a 17-year-old junior, said he used to be close friends with Cruz but had not seen him in more than a year following his expulsion from school.

“He started progressively getting a little more weird,” he said.

He recalled Cruz posting on Instagram about killing animals and said he had talked about target practice in his backyard with a pellet gun.

“He started going after one of my friends, threatening her, and I cut him off from there. I think everyone had in their minds if anybody was going to do it, it was going to be him.”

Students are released from lockdown (John McCall/South Florida Sun-Sentinel/AP)Students are released from lockdown (John McCall/South Florida Sun-Sentinel/AP)

Broward County School District Superintendent Robert Runcie told reporters on Wednesday afternoon that he did not know of any threats posed by Cruz to the school.

“Typically you see in these situations that there potentially could have been signs out there,” Mr Runcie said.

“I would be speculating at this point if there were, but we didn’t have any warnings. There weren’t any phone calls or threats that we know of that were made.”

READ MORE: Stars call for gun controls after Florida school mass shooting

A teacher told the Miami Herald that Cruz may have been identified as a potential threat to other students.

Jim Gard, a maths teacher who said Cruz was in his class last year, said he believes the school had sent out an email warning teachers that Cruz should not be allowed on campus with a backpack.

“There were problems with him last year threatening students, and I guess he was asked to leave campus,” Mr Gard said.