The gunman who allegedly killed at least 17 people at a Florida high school on Wednesday was a former student who posted disturbing material on social media and was "crazy about guns".
Police identified the suspect as Nikolas Cruz, a 19-year-old who had been expelled from Marjory Stoneman Douglas High School in Parkland, about 45 miles (72 km) north of Miami.
The suspect was wearing a gas mask and carrying smoke grenades, Sen. Bill Nelson of Florida told CNN.
Mr Nelson, who said he had been briefed by the FBI, said the attacker "set off the fire alarm so the kids would come pouring out of the classrooms into the hall. And there the carnage began."
He said he did not know if the gunman had used the smoke grenades but he assumed that's why he had a gas mask on.
Authorities later announced that they had taken the suspect into custody and took him to hospital after locating him in Coral Springs, a little over a mile away from the school. The gunman surrendered to police without a struggle, Broward County Sheriff Scott Israel said.
Inside the suspect's disturbing Instagram page
The Instagram page of the alleged shooter paints a picture of a man obsessed with guns and knives.
One of the more recent posts shows target practice, captioned "Group therapy. Sometimes it really f---ing works."
Others show him posing proudly with his weapons, which include pistols and knives, and in one Instagram post, he seemingly asks followers for advice on a certain model of gun.
He also posed for selfies where he wore all black clothes and a balaclava.
One photograph shows a dead toad, which he claims to have killed.
His Instagram profile contained the word “annihilator.”
One post about purchasing a shotgun reads: “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.
Students at the school have confirmed the Instagram page is his.
One student, who escaped the shooting, wrote on Twitter: "He literally had an Instagram where he posted pictures of animals he killed gruesomely."
Flagged as a threat
Jim Gard, a maths teacher, said Cruz had been in his class last year.
“We were told last year that he wasn’t allowed on campus with a backpack on him,” Mr Gard told the Miami Herald. “There were problems with him last year threatening students.”
However, Robert Runcie, the Broward County School District Superintendent, told reporters he was not aware of any concerns raised about the student.
“We received no warnings,” Mr Runcie said outside the school. “Potentially there could have been signs out there. But we didn't have any warning or phone calls or threats that were made.”
One student, who did not wish to be named, told TV station WSVN-7 that Cruz had said he had guns at home and talked about using them.
“He’s been a troubled kid,” the student said. “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.”
'Very disturbing' social media history
Mr Israel said the gunman had an AR-15 assault rifle and "countless magazines".
“We already began to dissect his websites and the things on social media that he was on and some of the things that came to mind are very, very disturbing," he said.
His Instagram account was taken down after the shooting, but screenshots were sent to various media outlets.
In almost every picture, he is said to be wearing a black shirt or scarf over his face, to conceal his identity.
One photo reportedly shows a used paper target from a shooting range, with the words “Group Therapy” underneath. “It really does f–king work,” the caption said.
Another post, from January 2016, shows an advertisement for a pump action shotgun.
“I plan on getting this but I need more information on it,” the caption said. “If someone could give advice on how much I’m spending and background checks please to god let me know.”
Former classmates and friends have confirmed to media that the account is his.
“Everything he posts is about weapons,” one student told ABC News. “It’s sick.”
Daniel Huerfano, a student who fled Wednesday's attack, said he recognised Cruz from an Instagram photo in which Cruz posed with a gun in front of his face. Huerfano recalled Cruz as a shy student and remembered seeing him walking around with his lunch bag.
"He was that weird kid that you see ... like a loner," he added.
One pupil said other teenagers had long thought the suspect would “shoot up the school”.
The pupil told local television station 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. That’s crazy.”
Broward County Mayor Beam Furr said during an interview with CNN that the shooter was getting treatment at a mental health clinic for a while, but that he hadn't been back 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."
Another student, named as Brandon, was asked whether he was surprised to learn the identity of the gunman, and replied: “No.” He continued: “He told me he got kicked out of two private schools, and was held back twice. He seemed a little off.”
'Crazy about guns'
Chad Williams, 18, a senior at Stoneman Douglas High school, remembered Cruz as a troubled classmate from when they attended middle school together. He said Cruz would set off the fire alarm, day after day, and finally got expelled in the eighth grade.
More recently, Williams saw Cruz carrying several publications about guns when they ran into each other at the high school. Williams thought Cruz was there to pick up a younger sibling.
“He was crazy about guns,” Williams told Reuters, speaking by the side of the road near the high school. “He was kind of an outcast. He didn’t have many friends. He would do anything crazy for a laugh, but he was trouble.”
Victoria Olvera, a 17-year-old junior, said Cruz was expelled last school year after a fight with his ex-girlfriend's new boyfriend. She said Cruz had been abusive to his girlfriend.
Dakota Mutchler, a 17-year-old junior, said he used to be close friends with Cruz but hadn't seen him in more than a year following his expulsion from school.
'If anyone would do it, it was him'
"He started progressively getting a little more weird," Mutchler said.
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," Mutchler said.
"I think everyone had in their minds if anybody was going to do it, it was going to be him," Mutchler said.
Travis Julmice, an 18-year-old senior, said he had not been in a class with Cruz since middle school.
"You could tell he was a little off," Julmice told Reuters at the Coral Springs hotel. "He was always like a troubled kid, getting in-school suspension a lot. And detentions."