The Florida school shooting suspect referred to himself as the "annihilator" and had been flagged as a potential threat before the massacre.
Accused gunman Nikolas de Jesus Cruz, 19, was a former student at Marjory Stoneman Douglas High School in Parkland, Florida, United States, where he allegedly returned and opened fire on students and teachers on Wednesday.
At least 17 people were killed and up to 50 injured in the shooting, which saw terrified teachers and students hiding in cupboards and under desks as they texted for help.
It is the ninth deadliest mass shooting in modern US history.
A former maths teacher at the school, Jim Gard, said Cruz had been previously identified as a security threat.
"We were told last year that he wasn't allowed on campus with a backpack on him," Gard told the Miami Herald. "There were problems with him last year threatening students, and I guess he was asked to leave campus."
Broward County Sheriff Scott Israel confirmed Cruz was a former student who had once been expelled for unspecified disciplinary reasons. He said Cruz was taken into custody without incident about an hour after committing the "horrible act".
"We have already begun to dissect his websites and things on social media that he was on and some of the things are very, very disturbing," Israel said.
"He had countless magazines, multiple magazines, and at this point, we believe he had one AR-15 rifle."
One student at the school told WSB-TV: "Everything he posts [on social media] is about weapons. It's sick."
Cruz's Instagram account, which has been deleted after the shooting, was brimming with images of firearms, knives and dead frogs. He described himself as the "annihilator" on his page. The photographs of guns and knives appear to show an obsession with weapons and have been posted as far back as 2015 and 2016.
In 2016, Cruz posted a photo of a shotgun advertisement and said he wanted to buy it, writing: "I plan on getting this but I need more information on it so if someone could give advice on how much I'm spending and background cheeks [sic] please to god let me know."
Another post featured a picture of a bullet-riddled bull's eye with the meme "Group therapy. Sometimes it works."
He wrote in a caption: "It really does f*cking work give it a try ;)."
Another post featured a selfie of himself with his face covered and giving the middle finger, captioning it: "F*ck youuuuuuuuuuuu allllll".
In another selfie he appears to display several knives.
He also posted a screenshot of a 2015 Google search for the Arabic phrase "Allahu Akbar" with the caption: "Well at least we now know what it means when a sand durka says 'allahu Akbar' ??????"
Giovonni Watford, 17, and Cruz were in the same Junior Reserve Officer Training Corps programme, which prepares students for the military, while studying at the school.
"He was off," Watford told BuzzFeed News.
"He was super stressed out all the time and talked about guns a lot and tried to hide his face."
Matthew Walker, a 17-year-old student at the school, told WFOR-TV that Cruz's classmates "knew it was going to be him" when news of the shooting spread.
"A lot of people were saying it was going to be him," Walker said.
"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. That's crazy.
"He was going class to class just shooting at random kids. He was prepared for this stuff."
One student told WSVN that Cruz made him nervous because he was obsessed with guns and had previously shown pictures of them on his phone.
"He's been a troubled kid and he's always had a certain amount of issues going on. He shot guns because he felt it gave him, I guess, an exhilarating feeling."
Another student at the school, who was in a separate building when the gunfire erupted, told the Daily News that she attended middle school with Cruz and remember him as "abusive".
"He used to punch walls," she said.
A former classmate described Cruz as someone who complained about bullying and "talked about guns a lot".
Cruz also complained often about bullying on campus and "had beef with one kid".
Watford's older brother, Mike, who graduated from the school in 2016, told BuzzFeed News that Cruz often mentioned "how tired he was of everyone picking on him and the staff doing nothing about it".
This morning, screenshots of two posts appearing to show Cruz's parents apologising for their son's alleged actions and linking them to his mental illness started circulating on social media.
One read: "We ask for nothing but forgiveness for our son's behaviour. We are grieving as much as you are please give us time to accept this reality [sic]".
The other said: "He was a nice loving kid and he loved nature but his mental illness got the best of him please stand by for further information. We beg for forgiveness."
Since January 2013, there have been at least 291 school shootings across the US — an average of about one school shooting a week, according to Everytown for Gun Safety, a non-profit group that advocates for gun control. Wednesday's mass shooting in Florida marked the 18th school shooting in the US this year.