Updated at 2:40 a.m. ET on Thursday

The Broward Sheriff's Office has identified the suspect in Wednesday's deadly school shooting as 19-year-old Nikolas Cruz, a former student who had been expelled for disciplinary reasons. Law enforcement says Cruz carried out the attack that killed at least 17 people at Marjory Stoneman Douglas High School and left others hospitalized with gunshot wounds.

Cruz is now in police custody after briefly receiving treatment at a local hospital.

Police say the young man was heavily armed when he carried out the attack, packing what they believe to be an AR-15 rifle and "countless magazines." Authorities say he opened fire outside the high school, which enrolls more than 3,200 students, then continued his rampage inside the building.

The AR-15 was legally purchased by Cruz, Jim Lewis, an attorney representing the family he was living with, told The Sun Sentinel. "The family made him keep it in a locked gun cabinet in the house but he had a key," Lewis said.

Even as officials gain a clearer understanding of how the shooter conducted the attack, law enforcement is opening its investigation into a still more difficult question: why.

"We have already begun to dissect his websites and social media that he was on," Sheriff Scott Israel said at a news conference Wednesday evening, "and some of the things that have come [up] are very, very disturbing."

Cruz's parents are both deceased. His mother, Lynda Cruz, died of pneumonia less than four months ago at age 68, and his father, Roger Cruz, died when Nikolas and his biological brother, Zachary — also adopted by the Cruz family — were much younger, according to The Sun Sentinel.

Barbara Kumbatovich, a sister-in-law of Lynda's who lives on Long Island, N.Y., tells the newspaper that the brothers moved in with a family friend after their mother's death on Nov. 1.

"I know [Lynda] had been having some issues with them, especially the older one. He was being a problem. I know he did have some issues and he may have been taking medication. [He] did have some kind of emotional or difficulties," Kumbatovich told the paper.

The family that took Cruz into their home "got him a job at the local dollar store. They didn't see anything that would suggest any violence," Lewis said, according to The Washington Post.

"He was depressed, maybe a little quirky. But they never saw anything violent," the attorney said.

Police do not yet know the specific reason for Cruz's expulsion, besides the fact that it was tied to a disciplinary issue. Lissette Rozenblat, the mother of a student at Marjory Stoneman Douglas High, told All Things Considered that her daughter was familiar with Cruz from previous aggressive incidents.

"She knew who the kid was," Rozenblat said. "Because back when she was a freshman, I remember her coming home and telling me a story that a kid bumped into her and was really rude and was like, 'Get out of the way, freshman!' And he bumped her. She came home and told me that story, and it stuck in my mind."

Rozenblat said that her daughter made the connection after the shooting, when she visited the purported Instagram account of the shooter.

The account her daughter found "is just full of pictures of guns — and she goes, 'That's the kid! That's the kid that bumped into me and was so rude to me when I was a freshman.' You know, it's pretty scary when you recognize somebody who did this."

Jim Gard, a math teacher who says he had Cruz in his class, told The Miami Herald that the young man had attracted the school's notice, as well.

"We were told last year that he wasn't allowed on campus with a backpack on him," Gard said. "There were problems with him last year threatening students, and I guess he was asked to leave campus."

County school superintendent Robert Runcie, for his part, told a news conference on Wednesday afternoon that new information may come to light, but at the moment, officials believe they had "received no warnings, no indication" that a student had been planning an attack.

Copyright 2018 NPR. To see more, visit http://www.npr.org/.