The gunman in Tuesday's elementary school massacre was a lonely 18-year-old who was bullied over a childhood speech impediment, suffered from a fraught home life and lashed out violently against peers and strangers recently and over the years, friends and relatives said.

Using weapons purchased this month, days after his 18th birthday, authorities said, Salvador Rolando Ramos shot and critically wounded his grandmother. He then went on a shooting rampage at Robb Elementary School near his home in Uvalde, Texas, killing at least 19 children and two adults and injuring others.

Ramos also was fatally shot, apparently by police. The Texas Department of Public Safety said he was wearing body armor and armed with a rifle.

Santos Valdez Jr., 18, said he has known Ramos since early elementary school. They were friends, he said, until Ramos's behavior started to deteriorate.

They used to play video games like "Fortnite" and "Call of Duty." But then Ramos changed. Once, Valdez said, Ramos pulled up to a park where they often played basketball and had cuts all over his face. He first said a cat had scratched his face.

"Then he told me the truth, that he'd cut up his face with knives over and over and over," Valdez said. "I was like, 'You're crazy, bro, why would you do that?'"

Ramos said he did it for fun, Valdez recalled.

In middle school and junior high, Ramos was bullied for having a stutter and a strong lisp, friends and family said.

Stephen Garcia, who considered himself Ramos's best friend in eighth grade, said Ramos didn't have it easy in school. "He would get bullied hard, like bullied by a lot of people," Garcia said. "Over social media, over gaming, over everything."

"He was the nicest kid, the most shyest kid. He just needed to break out of his shell."

One time, he posted a photo of himself wearing black eyeliner, Garcia said, which brought on a slew of comments using a derogatory term for a gay person.

Garcia said he tried to stand up for him. But when Garcia and his mother relocated to another part of Texas for her job, "he just started being a different person," Garcia said. "He kept getting worse and worse, and I don't even know."

When Garcia left, Ramos dropped out of school. He started wearing all black, Garcia said, and large military boots. He grew his hair out long.

He missed long periods of high school, classmates said, and was not on track to graduate with them this year.

Ramos's cousin Mia said she saw students mock his speech impediment when they attended middle school together. He'd brush it off in the moment, Mia said, then complain later to his grandmother that he didn't want to go back to school.

"He wasn't very much of a social person after being bullied for the stutter," said Mia, who spoke on the condition that her last name not be used because her family does not want to be associated with the massacre. "I think he just didn't feel comfortable anymore at school."

Valdez said Ramos drove around with another friend at night sometimes and shot at random people with a BB gun. He also egged people's cars, Valdez said.

About a year ago, Ramos posted on social media photos of automatic rifles that "he would have on his wish list," Valdez said. Four days ago, he posted images of two rifles he referred to as "my gun pics."

A person briefed on the investigation's early findings, who spoke on the condition of anonymity because they were not authorized to discuss the case, said Ramos bought the weapon used in the attack immediately after his 18th birthday, which was in mid-May.

Two months ago, he posted an Instagram story in which he screamed at his mother, who he said was trying to kick him out of their home, said Nadia Reyes, a high school classmate.

"He posted videos on his Instagram where the cops were there and he'd call his mom a b---- and say she wanted to kick him out," Reyes said. "He'd be screaming and talking to his mom really aggressively."

Ruben Flores, 41, said he lived next door to the family on Hood Street and tried to be a kind of father figure to Ramos, who had "a pretty rough life with his mom."

He and his wife, Becky Flores, would invite Ramos to barbecues at their house and for sleepovers with their son, who was a few years younger. Ramos went by the nickname "pelon," Spanish for bald, because his hair was often cut so short when he was younger, Flores said.

As he grew older, problems at home became more acute and more apparent to neighbors, Flores said. He described seeing police at the house and witnessing blowups between Ramos and his mother.

Multiple people familiar with the family, including Flores, said Ramos's mother used drugs, which contributed to the upheaval in the home. Ramos's mother could not be reached for comment.

Ramos moved from the Hood Street home to his grandmother's home across town a few months ago, Flores said. He said he last saw the grandmother on Sunday, when she stopped by the Hood Street property, which she also owned. The grandmother told him she was in the process of evicting Ramos's mother because of her drug problems, Flores said.

Reyes said she could recall about five times that Ramos had fistfights with peers in middle school and junior high. His friendships were short-lived, she said. Once, Ramos commented to a friend while playing basketball that the friend only wanted to join the Marines one day so that he could kill people, Reyes said. The other boy, she added, ended the friendship on the spot.

"He would take things too far, say something that wouldn't be said, and then he would go into defense mode about it," Reyes said.

She and her Uvalde High School school classmates had visited Robb Elementary School just a day before the massacre, wearing their graduation robes and high-fiving the grade-schoolers, who lined up in the hallways - a community tradition.

"Those kids were so excited to see us in our cap and gown," Reyes said. "They're looking at us like, 'I'm gonna be there one day.' It's surreal, like we're in a movie. It's horrible."

Valdez said his last interaction with Ramos was about two hours before the shooting, when they messaged on Instagram's Stories feature. Valdez had re-shared a meme that said "WHY TF IS SCHOOL STILL OPEN"

According to a screenshot of their exchange, Ramos responded: "Facts" and "That's good tho right?" Then Valdez replied: "Idek [I don't even know] I don't even go to school lmao."

Ramos never responded to or opened that text message, Valdez said.

Just a month or two ago, Garcia said, he called Ramos to check in on him.

But Ramos said he was going hunting with his uncle and didn't have time to talk. He hung up. Garcia later saw the photos of large guns that Ramos had posted online and wondered whether that was what they were for — going hunting, or to the shooting range with his uncle.

On Tuesday, Garcia was in algebra class in San Antonio when he started receiving a slew of texts with the news of what had happened in Uvalde. He didn't believe it at first. He opened his phone's browser and Googled the shooting and saw Ramos's name.

"I couldn't even think, I couldn't even talk to anyone. I just walked out of class, really upset, you know, bawling my eyes out," Garcia said. "Because I never expected him to hurt people."

"I think he needed mental help. And more closure with his family. And love."

- - -

The Washington Post's Arelis R. Hernández in Uvalde, Texas, and Devlin Barrett in Washington contributed to this report.