(CNN)The suspect who killed 19 kids and two teachers at an elementary school in Uvalde, Texas, was a local high school student with few if any friends who officials said legally purchased two assault rifles and scores of ammo last week for his 18th birthday.
Salvador Ramos was identified as the gunman who stormed into Robb Elementary on Tuesday with an assault rifle and tactical vest, barricaded himself in adjoining classrooms of children and opened fire, authorities said. Responding officers eventually forced their way into the room and a Border Patrol officer fatally shot him.
The heinous attack came just two days before students were set to be released for the summer and left a community and nation asking yet again: Who would do this, and why?
An examination of Ramos' personal background reveals a bullied loner with no criminal history and -- like so many other mass shooters in America -- interest in and access to high-powered firearms and ammunition in a political system that prioritizes gun rights.
He purchased guns and ammo last week
The suspect's actions leading up to the shooting offer hints at his mindset and plan.
Ramos legally purchased two AR platform rifles at a local federal firearms licensee on May 17 and on May 20, according to state Sen. John Whitmire, who received a briefing from law enforcement Tuesday night. He also purchased 375 rounds of ammunition on May 18, Whitmire said, citing law enforcement.
State Sen. Ronald Gutierrez, who represents Uvalde, said the purchases were made for the suspect's 18th birthday.
"It's the first thing he did when he turned 18," he told CNN's Erin Burnett on Tuesday evening, citing a briefing he received from Texas Rangers.
Gutierrez said the guns were bought legally from a federally authorized dealer in the Uvalde area. "(He) had no problem accessing those weapons," he said.
A photo of two AR15-style rifles appeared on an Instagram account tied to the suspect just three days before the massacre. The photo was posted as a story under the username "salv8dor_." Multiple classmates confirmed the account belonged to the suspected gunman.
He shot his grandmother and crashed vehicle before entering school
His shooting spree began Tuesday prior to arriving at Robb Elementary. Ramos first shot his grandmother at her home and then fled the scene, authorities said. The grandmother was airlifted to a hospital and was being treated in serious condition, officials said Wednesday.
"The first thing that happened was the gunman shot his grandmother ... She then contacted police. The gunman fled, and as he was fleeing had an accident just outside the elementary school and he ran into the school," Gov. Greg Abbott said at a news conference Wednesday.
From there, the suspect crashed his vehicle into a ditch near the elementary school and emerged with a rifle and a backpack while wearing a tactical vest that holds extra ammunition, Texas Department of Public Safety (DPS) Sgt. Erick Estrada said.
Ramos moved toward the school and entered through a back door, DPS Director Steven McCraw said. A school resource officer "engaged" him but no shots were fired, he said.
The suspect dropped a bag full of ammunition outside of the school during that encounter and ran inside, Estrada told CNN's Wolf Blitzer. DPS is investigating what happened during the interaction with the officer.
The suspect then barricaded himself in a classroom and an adjoining classroom opened fire at those inside. All of the 19 children and two teachers killed were in those rooms, DPS spokesperson Lt. Chris Olivarez said.
"The initial group of officers that were on scene, at that point, they were at a point of disadvantage because the shooter was able to barricade himself inside that classroom. There was not sufficient manpower at that time and their main, their primary focus was preserve any further loss of life," Olivarez said. "So they started breaking windows around the school, and trying to rescue, evacuate children and teachers while that was going on."
A specialized tactical team forced their way into the classroom and fatally shot the suspect, Olivarez said. One officer was shot and had a non-life-threatening injury, he added.
Uvalde firefighter Chip King told CNN's Jim Sciutto that it took about 30 minutes after he arrived on the scene for the gunman to be neutralized by law enforcement.
The shooter was on the premises for up to an hour before law enforcement forcibly entered a classroom and killed him, officials said Wednesday. "It's going to be within, like 40 minutes or something, [within] an hour," McCraw said.
Investigators found one of the suspect's rifles, manufactured by Daniel Defense, in the school with the suspect, Whitmire said, citing the ATF. The gunman's other rifle was left in the truck that crashed.
The suspect dropped a backpack with several magazines of ammunition near the entrance of the school, authorities told the state senator. Inside the school, authorities found what appears to be seven 30-round magazines.
He was a local student with few if any friends
Those who knew the suspect personally largely described him as a loner with little if any social life.
The suspect attended a local high school and lived with his grandparents, Olivarez said. He had no friends and had no criminal history or gang affiliation, he added.
He worked the day shift at a local Wendy's and kept mostly to himself, the restaurant's manager confirmed to CNN.
"He felt like the quiet type, the one who doesn't say much. He didn't really socialize with the other employees," Wendy's evening manager Adrian Mendes said. "He just worked, got paid, and came in to get his check."
A former classmate of the gunman said Ramos "would get severely bullied and made fun of a lot" and was taunted by others for the clothes he wore and his family's financial situation. "People would, like, actually call him school shooter and stuff like that," he said.
The classmate, who did not want to be identified by name, said he was somewhat "close" to Ramos. They sat together through high school and played Xbox together, he said.
The suspect had stopped attending school regularly and they communicated less aside from occasional invites to play Xbox. Recently, the suspect sent the classmate a picture of an AR-15, a backpack with rounds of ammunition and several gun magazines, he added.
"I was like, 'Bro, why do you have this?' and he was like, 'Don't worry about it,'" the friend said. "He proceeded to text me, 'I look very different now. You wouldn't recognize me.'"
Stanley Torres, a senior at Uvalde High School, told CNN he shared a gym class with Ramos and described him as a "very quiet person who hung out by himself." Another Uvalde High senior told CNN she "knew people didn't like him. People would make fun of him or want to fight him," but she said she wasn't sure why.
According to one former friend and a video obtained by CNN, the shooter had a history of physically fighting with others. The former friend and classmate said Ramos sent him the video on Snapchat more than a year ago. It depicts the shooter fighting with someone else, which the former friend said was not out of the ordinary, adding, "he would always get in fights in school."
Two other former classmates told CNN the person in the video is Ramos.
The suspect had no known mental health history, Abbott said.
He made warnings on social media messages
Hours before the shooting, the gunman made a series of ominous messages on different social media sites.
The Instagram account that was linked to Ramos posted a photo of two rifles lying on a carpet and also tagged another Instagram account by name in the photo. The owner of the tagged Instagram account wrote in a story posted after the shooting that the suspect had tagged her and messaged her out of the blue.
The girl, who did not include her name on her account and has since made her account private, posted screenshots of messages that she said she exchanged with the shooter in the days before the massacre.
In one, Ramos wrote "I'm about to" -- but didn't say what he would do. "I got a lil secret," he wrote in another message. "I wanna tell u." She responded she might take a nap soon but would respond if she was awake.
In messages posted to her story before it went private, the girl said that she didn't live in Texas and didn't know Ramos.
"the only reason i responded to him was because i was afraid of him i wish i stayed awake to at least try to convince him to not commit his crime," she wrote. "I didnt know."
Abbott said the gunman wrote about his intentions on Facebook. A spokesman for Meta, Facebook's parent company, said the gunman's private one-to-one messages were discovered after the shooting.
Abbott said that in the first of three messages, about 30 minutes before the school shooting, Ramos wrote, "I'm going to shoot my grandmother."
Shortly after, he wrote, "I shot my grandmother."
And finally: "I'm going to shoot an elementary school."
He allegedly sent similarly chilling text messages to a girl he met online describing how he had just shot his grandmother and was going to shoot up an elementary school.
The 15-year-old girl, who lives in Frankfurt, Germany, said she began chatting with Ramos on a social media app on May 9. She said she spoke daily on FaceTime with him and also communicated with him on other apps.
In their conversations, she said he asked about her life in Germany. "He looked happy and comfortable talking to me," the girl said. She said he told her he spent a lot of time alone at home.
There were other text messages, however, that alarmed her. In one case, she said, he told her that he "threw dead cats at people's houses."
She said she got the impression that he kept to himself.
"Every time I talked to him," she said, "he never had plans with his friends."
CNN's Curt Devine, Virginia Langmaid, Daniel A. Medina, Raja Razek, Paula Reid, Ed Lavandera, Casey Tolan and Jeff Winter contributed to this report.