Teachers were warned not to let suspected Florida school shooter Nikolas Cruz on to campus wearing a backpack, a staff member has said, as details emerged of “very disturbing” social media posts left by the teenager.

Seventeen people were killed at Marjory Stoneman Douglas High School, in Parkland, when the 19-year-old allegedly opened fire with an AR-15 semi-automatic assault-style rifle on Wednesday. Police said he was carrying “countless” extra magazines of ammunition.

But as a picture of the suspect began to emerge, maths teacher Jim Gard said there had been “problems with him last year threatening students” and that he had been asked to leave.

Senior staff had emailed teachers to warn them “that he wasn’t allowed on campus with a backpack on him”, he told the Miami Herald.

Cruz has now been charged with 17 counts of premeditated murder.

Fellow students claimed they had joked about Cruz as a future killer, with one telling WFOR-TV: “A lot of people were saying it was going to be him. A lot of kids threw jokes around saying that he was going to be the one to shoot up the school. It turns out that everyone predicted it.”

Daniel Huerfano, a student who fled Wednesday’s attack, said he recognised Cruz from an Instagram photo in which he posed with a gun in front of his face. “He was that weird kid that you see ... like a loner”, he added.

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, and that “he started progressively getting a little more weird”.

Mr Mutchler recalled Cruz posting on Instagram about killing animals and said he had talked about doing 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”, he added.

A third student alleged Cruz had been abusive towards an ex-girlfriend.

On his now-deleted Instagram profile were images of multiple knives and guns. One showed a box of 150 rifle rounds and another sought advice on buying a shotgun.

A law enforcement official close to the investigation told AP after Cruz was charged, early on Thursday, that the teen had bought his AR-15 legally.

A photograph first tweeted by a local ESPN radio reporter showed Cruz at the moment of his arrest wearing a Reserve Officers’ Training Corps (ROTC) t-shirt. Police sources told the New York Post he was a member of the US Army junior ROTC group.

Florida shooting suspect Nikolas Cruz appears in court the day after mass shooting

Broward County Sheriff Scott Israel said Cruz had been expelled for “disciplinary reasons” but that “I don’t know the specifics”.

The county’s mayor, Beam Furr, told CNN Cruz had received some mental health treatment but had not attended a clinic for more than a year.

The Orlando Sentinel quoted family members as saying Cruz had been adopted at birth along with his brother by Lynda and Roger Cruz. Mr Cruz died some years ago and his widow passed away last November, the paper said.

Her sister-in-law, Barbara Kumbatovich, told the Sentinel Ms Cruz had sought counselling for Nikolas when he was younger. The boys were left in the care of a family friend after their mother died, she added.

Unhappy there, Cruz asked to move in with a friend’s family in north-west Broward. The family agreed and Cruz moved in around Thanksgiving.

Florida shooting – in pictures Show all 10 1 /10 Florida shooting – in pictures Florida shooting – in pictures Police arrest a suspect in connection with the shooting at the Marjory Stoneman Douglas High School in Parkland, Florida Reuters Florida shooting – in pictures Parents wait for news after reports of a shooting at Marjory Stoneman Douglas High School in Parkland, Florida AP Florida shooting – in pictures Anxious family members wait for news of students AP Photo/Wilfredo Lee Florida shooting – in pictures Students being evacuated from the school AP Florida shooting – in pictures Students being evacuated from the school Getty Florida shooting – in pictures People gather waiting for word from students AP Florida shooting – in pictures Parents waiting for news on their children AP Florida shooting – in pictures People gather at a hotel where students were taken after the shooting Getty Florida shooting – in pictures Florida Governor Rick Scott speaks to the media as he visits Marjory Stoneman Douglas High School following the shooting AFP/Getty Florida shooting – in pictures Dr. Igor Nichiporenko, Medical Director Trauma, left, and Dr. Evan Boyer, Medical Director, Emergency Services, speak about treating victims and the suspect at a press conference outside Broward Health North hospital AP

According to the family’s lawyer, who did not identify them, they knew that Cruz owned the AR-15 but made him keep it locked in a cabinet. He did have the key, however.

The lawyer, Jim Lewis, said the family was devastated and was cooperating with police. They had not seen the tragedy coming, he said.