Rich Pasqua, who graduated from high school a few years ahead of Mr. Kohberger, said they used heroin together in 2013 and 2014, at a time when they both worked at a pizza shop called New York Pizza Girl, in Effort, Pa.

Mr. Pasqua, now 31, recalled that Mr. Kohberger was socially awkward and did not appear to have many friends, frequently calling him and offering to share his marijuana. Mr. Pasqua, who said he is now sober and working at a rehabilitation center, recalled in one instance driving with Mr. Kohberger through the gated community where Mr. Kohberger’s parents lived, trying to evade a private security guard.

“We would make it to a cul-de-sac and we’d see their orange lights and Bryan would be like, ‘Go this way!’” Mr. Pasqua recalled. “He was like, ‘We’re going to get in so much trouble.’”

Mr. Pasqua said his wife, who was in Mr. Kohberger’s year, remembered that Mr. Kohberger had been heavier when he was in high school and was bullied over his weight. (Mr. Kohberger wrote in the online forum in 2011 of having lost half his body weight.) And Mr. Pasqua recalled teasing him on one occasion as well, telling Mr. Kohberger to walk to the private community’s gates in the snow to get some heroin from him, only to not be there when he showed up.

Eventually, Mr. Pasqua said, Mr. Kohberger’s father would pick up the phone when he called, once saying that his son was “on a top-secret mission,” which Mr. Pasqua realized meant he was in rehab.

Years later, Mr. Kohberger appeared to be doing much better, studying psychology at DeSales University in Eastern Pennsylvania and telling one friend that his drug problems were in the past.

“I only used when I was in a deep suicidal state,” Mr. Kohberger wrote in May 2018 to Mr. Baylis, with whom he had been friends since eighth grade. “I have since really learned a lot. Not a person alive could convince me to use it.” Mr. Kohberger followed up later that day, telling Mr. Baylis that he had been off drugs for two years and telling him to not mention his drug use again, according to screenshots of their conversation on Facebook Messenger.