Charles Pelkey had known Matthew Riehl for years going back to law school, when their relationship was still good and long before sheriff’s deputies went inside Riehl’s apartment — and he and an officer ended up dead.

When Pelkey was going through cancer treatment after a diagnosis in 2011, he said Riehl called him to see how he was doing and suggested some alternative treatments. After Riehl started a solo law practice in Wyoming, Pelkey sent clients his way when his firm could not take the cases.

The two men, who both graduated from the University of Wyoming, were friendly — until last summer.

They got into a heated argument on Facebook over President Trump’s policy of not allowing transgender individuals to serve in the military. Pelkey, a Democratic state representative in Wyoming, was against it. He said Riehl disagreed with him and insulted him and others who joined the conversation. Pelkey said he deleted the comments, prompting Riehl to come back with even more vitriolic and transphobic posts in all caps.

He blocked Riehl on Facebook. He said he did not talk to or hear about Riehl again — until this week.

Authorities say the 37-year-old killed Douglas County sheriff’s deputy Zackari Parrish and wounded four other officers and two civilians early Sunday morning, when residents in a Denver-suburb apartment complex were awakened by a barrage of gunfire.

Accounts from Riehl’s former law-school classmates and reports from law-enforcement agencies in at least two states paint a picture of a man whose problems with mental illness seemed to finally boil over. Police in Colorado and Wyoming had known about Riehl for years through several reports of harassment and emergency calls from his parents, though nothing appeared to have resulted in arrests.

A timeline released by the police department in Lone Tree, Colo., where Riehl’s family lives, show a troubling pattern within the past two years.

Police went to Riehl’s family’s house in June 2016 after he got into a fight with his father, authorities said. The family did not press charges, and Riehl left. Last June, Riehl’s mother, concerned for his mental condition, asked police to check on her son. Officers talked to Riehl for a few minutes through a closed door as he repeatedly assured them he was not a danger to himself. Authorities said the family denied mental health services that were offered.

Police were back at the house in August. This time Riehl called to say his mother and brother had made a suicide pact. Officers later found those claims were not true, and Riehl had moved out of the house a month earlier.

In 2014, Riehl apparently escaped from a mental health ward of a veterans hospital in Wyoming, where he was staying after a psychotic episode. The Denver Post obtained a one-page document saying Riehl had problems with mental illness as recently as April 2014, when he escaped, was brought back and placed on a 72-hour hold. He had an “urgent contact for Mental Health” and a “mental health assessment” in the summer of 2015, the Denver Post reported.

He skipped an appointment later that year and declined another clinic visit in 2016 — the same year Riehl withdrew his membership from the Wyoming State Bar, to which he was admitted in 2011. According to the website, he worked for a law firm in Rawlins, Wyo. At some point, he had his own practice in Rawlins.

It remains unclear what pushed Riehl over the edge, and according to the Denver Post, the document did not say what caused his psychotic episodes. A call to a number registered to family members was not returned Wednesday.

Pelkey, the former law-school classmate, said Riehl’s mind “wandered into some really strange places” even when they were in law school 10 years ago. His sense of humor was a bit strange and often juvenile, Pelkey said, though he could not recall specific conversations with Riehl. He didn’t sense a deeper problem then, or even after their Facebook argument, which Pelkey said he chalked up as “mere incivility” — something he said he now regrets.

“Something happened in the last couple of years. He became more and more — I guess I’ll use the word paranoid . . . Matt is an example of someone who fell through the cracks, who needed help and wasn’t getting [it],” Pelkey said.

Izaak Schwaiger, another former classmate, believes Riehl had been disturbed long before he joined the military. Schwaiger, now a lawyer in California, declined to be interviewed, but in a lengthy Facebook post, he described Riehl as a “sad, immature man whose soul was stunted.”

He said he and a friend were out hunting with Riehl in 2007. Riehl was a first-time hunter, intent on getting “his first kill” but didn’t know how to use the rifle he had brought, Schwaiger said, recalling Riehl’s words.

“Matt showed up with a .300 WSM, way more gun than any neophyte shooter has business shooting . . . There he was out there on the prairie — a small and puny kid with a thousand-dollar rifle that just wanted to kill something for the sake of killing it,” Schwaiger said, adding later: “Matt was damaged goods, but not so visibly so that he couldn’t get into the Army, get into law school, pass the bar exam, get a letter of moral character and fitness from the university, and be a licensed attorney.”

Riehl was deployed to the Middle East in 2009 as a member of the Wyoming Army National Guard, spokesman Kurt M. Rauschenberg said. He was honorably discharged in 2012 and had been a member of the Army Reserves before joining the National Guard.

Riehl had been known to law enforcement since at least the year before his deployment. Police Chief Mike Samp, of the University of Wyoming’s police department, said Riehl was investigated for harassment in 2008, though details were unclear and charges were never filed.

Campus police would hear about Riehl again seven years after he graduated. Police found out last October that Riehl had been posting vulgar messages about professors and making veiled threats on social media, Samp said. The threats were too vague to warrant any charges, but school officials saw him as a potential threat. Students, faculty and staff received a warning to be on the lookout for Reihl, said university spokesman Chad Baldwin.

“We did provide extra security staff for a brief period of time until we were able to determine where he was physically residing,” Samp said.

In the weeks leading up to the shooting, Riehl had been making nonsensical ramblings and anti-police comments on YouTube.

The police department in Lone Tree, just east of Highlands Ranch, Colo., where the shooting occurred, said Riehl sent harassing emails to police officers after he was pulled over and ticketed for speeding in November. Riehl complained he was unjustly treated and asked for body camera footage of the traffic stop, said Sgt. Tim Beals, a police spokesman.

Riehl also posted the videos on YouTube and called the officer who ticketed him “dirty.”

In one YouTube video posted in December, Riehl, wearing a military hat, said he’s running to be sheriff of Douglas County and insulted Sheriff Tony Spurlock and one of his deputies.

“I’m just here to inform you, this department is run by a pimp. This particular deputy is a pimp in the field and I’m Matt Riehl running for libertarian candidate . . . I flub every once in a while, but we all do, and you know who’s gonna flub big time next election? Spurlock. He’s a clown and so is his whole posse and crew,” Riehl said.

Hours before the shooting, Riehl was on Periscope, rambling as he sipped Scotch whisky.

He had bought more than 1,000 rounds of ammunition from Walmart, he said. The man he was living with “totally freaked out” on him, he told a 911 dispatcher. The live-streaming app captured his brief interaction with sheriff’s deputies after he called 911 at about 3 a.m. and complained about his domestic partner, according to media outlets that reviewed the videos before they were taken down.

He was “assaulted” and wanted to file a restraining order against his domestic partner, even as he told deputies there was no physical contact. Riehl grew angrier. “They lied,” he can be heard saying as he appeared to turn his back at the officers.

Officers received a second 911 call two hours later. Authorities said Riehl’s roommate, who had left the apartment, gave the officers a key to get in. Periscope captured Riehl’s screams and the series of gunshots that confronted the deputies after they arrived, the Denver Post reported.

Authorities said Riehl barricaded himself inside a bedroom while he fired rounds from a rifle. Parrish, the slain deputy, was shot multiple times. The other deputies were able to crawl to safety as bullets continued to fly at them, but they were unable to pull Parrish out because of their injuries, Spurlock, the sheriff, said.

A SWAT team went inside the apartment around 7:30 a.m. Riehl was shot and killed, while an officer from another police department was injured during an exchange of gunfire. At one point before he was killed, Riehl also shot two civilians, the sheriff’s office said.

Riehl had unleashed at least 100 rounds of ammunition, authorities said.

Parrish, a 29-year-old deputy who began working for the sheriff’s office just seven months ago, left behind a wife and two young children. The other deputies were in stable condition, and the civilians had non-life-threatening injuries, authorities said.

In a lengthy Facebook post Monday, Pelkey, the former law-school classmate, extended his condolences.

“As for Matt,” he wrote, “I don’t know.”

Eli Rosenberg contributed to this story.

Read more: