(CNN) The gunman who killed 19 kids and two teachers at a Texas 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 entered 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 -- an interest in and access to high-powered firearms and ammunition in a political system that prioritizes gun rights.
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. Roland 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.
The shooting spree began Tuesday prior to Ramos 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," Gov. Greg Abbott said at a news conference Wednesday.
The suspect crashed his vehicle into what appears to be a flood control channel 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.
The door had just been propped open by a teacher about a minute before Ramos' truck crashed near the school, McCraw said at a briefing Friday, citing video evidence.
Initially, authorities said a school resource officer "engaged" him, but no shots were fired.
On Thursday, DPS Regional Director Victor Escalon offered a different account of what happened, saying Ramos walked into the school without any confrontation from officers.
McCraw said at a news conference Friday that when two men at a nearby funeral home heard Ramos' truck crash, they went to see what happened. But when they saw a man with a gun get out of the truck, they ran. Ramos fired at them, but did not hit either man, McCraw said.
Video inside the school shows a teacher grab her phone and she "apparently calls 911," McCraw said. The teacher tells dispatchers that there was a crash outside and a man with a gun.
Ramos then walked toward the school and began shooting at the building while officers arrived at the funeral home, McCraw said. The patrol car then sped toward the school, but drove right past the shooter, who was "hunkered down" between cars in the parking lot.
At 11:33 a.m. local time, Ramos entered the school through the propped-open door and began shooting into the first classroom. He "shot more than 100 rounds based on the audio evidence at that time," McCraw said. In total, hundreds of shots were fired in just four minutes.
The suspect then barricaded himself in a classroom and an adjoining classroom. All of the 19 children and two teachers killed were in those rooms, DPS spokesperson Lt. Chris Olivarez said.
A total of seven officers were on scene within minutes, including six Uvalde Police officers and a county deputy sheriff, according to McCraw. Two of the officers received grazing wounds from the suspect. Eventually, a total of 19 officers were on scene.
"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."
Nearly an hour later, a specialized tactical team entered the locked classroom using keys obtained from the janitor and fatally shot the suspect, McCraw said. One officer was shot and had a non-life-threatening injury, he added.
McCraw explained the delay in entering by saying the officers on scene had switched from active shooter mode to trying to address someone who had barricaded himself in the classroom and may have been trying to entice officers to enter.
"From the benefit of hindsight where I'm sitting now, of course it was not the right decision. It was the wrong decision, period. There's no excuse for that," McCraw said.
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, along with 15 magazines, according to McCraw.
McCraw said 58 magazines were found at the school -- 11 inside the school, three on the shooter's body, two in Room 112, six in Room 111, five on the ground, and one was in the rifle. Thirty-two magazines were located outside the school, with most of them in a backpack he dropped outside. There were another two magazines found at his home, for a total of 60.
He had a total of 1,657 rounds of ammunition, McCraw said.
Ramos' grandfather, Rolando Reyes, told CNN on Thursday that he knows many of the families whose loved ones endured the mass shooting.
Some of them are my friends, and I'm going to have to face them some day," Reyes said.
Reyes' wife, the shooter's grandmother, suffered from a bullet that pierced her jaw and upper cheek and will undergo significant reconstructive surgery. Reyes said he doesn't understand why Ramos shot his grandmother, who took care of him.
Those who knew the shooter personally largely described him as a loner with little if any social life.
Ramos 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.
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.
"Tthe 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."
In other group messages on Instagram from February, there was talk of Ramos being a school shooter, McCraw said. In March, there were more group chats on Instagram about Ramos buying a gun. McCraw said that last year Ramos had asked his sister to buy him a gun "but she flatly refused."
Correction: Previous versions of this article had the wrong name for state Sen. Roland Gutierrez.