DENVER -- He was once a standout student in law school and an Army medic who deployed to Iraq.
By last weekend, he lay dead in a Colorado apartment building, killed by a SWAT team after he gunned down a 29-year-old deputy.
Matthew Riehl's six-year descent from a budding attorney to a gunman who live-streamed some of the final violent hours of his life was accompanied by episodes of mental illness, according to police and a document from the Department of Veterans Affairs.
Three days after the gun battle with authorities, it was still unclear whether Riehl's problems were grave enough to legally disqualify him from buying a weapon. Police have said he had a rifle, but they haven't released details about what weapons were used or how he obtained them.
Federal standards prevent anyone from buying a gun who has been determined to be a danger to themselves or others by a court or other authority. People who have been involuntarily committed to a psychiatric institution also can't buy from federally licensed gun dealers.
Riehl was hospitalized at a VA psychiatric ward in Wyoming in 2014, and at one point he was placed under a 72-hour mental health hold there, according to a VA document obtained by The Associated Press and other news outlets this week.
But the agency declined to say whether that treatment meant Riehl should not have been allowed to own a gun.
Stephen Fischer, a spokesman for the FBI division that manages the background-check databases used for gun purchases, didn't immediately respond Wednesday to a request for more information.
KDVR-TV in Denver reported Wednesday that Riehl had purchased 11 firearms from a store in Laramie, Wyoming, between 2010 and 2013, but it wasn't immediately known whether any of those guns were used in the Colorado shooting.
A Laramie Police Department report said David Smith, owner of Dave's Guns, told police Riehl passed the required background checks. No one answered an after-hours call to Smith's store Wednesday.
Revelations about Riehl's mental health history came to light amid increased scrutiny of background-check databases.
After former Air Force member Devin P. Kelley massacred 26 people at a Texas church in November, the Air Force acknowledged it failed to alert the FBI that he had a criminal history.
Kelley had been convicted of assaulting his then-wife and stepson in 2012, when he was still in the Air Force. The military never reported the conviction to the FBI, which should have stopped Kelley from buying weapons, and later blamed training and compliance measures. Kelley was found dead after the killings.
In Riehl's case, a sketchy but striking picture of his life began to emerge. He joined the Army Reserve in 2003 and later the Wyoming Army National Guard, serving as a medic. He enrolled in the University of Wyoming College of Law and was named to the dean's honor roll in fall 2007.
He interrupted school to serve a tour of duty in Kuwait and Iraq from 2009 to 2010. Returning to law school, he won a coveted spot on a team of students that sometimes got to argue before the Wyoming Supreme Court. He graduated in 2011 and left the military with an honorable discharge in 2012.
Some news reports have cited people who described Riehl sometimes behaving oddly in law school.
Riehl's records did not show any military service-related psychiatric disorders, according to the VA document. But within two years of his discharge, he appeared to lose his way: In April 2014, he suffered a psychotic episode and was hospitalized in the mental health ward of the Sheridan, Wyoming, veterans hospital, the document said.
He escaped but was found and returned, the document said. A year later, in June 2015, he had an "urgent contact for mental health" with a different VA hospital, according to the document.
It offers few details and does not describe the nature of Riehl's psychiatric problems. The VA has refused to elaborate, citing privacy concerns.
By mid-2016, Riehl was at the center of a string of worrisome events reported by police in Colorado and Wyoming: A fight with his father and a call to police from his mother, who was concerned about his mental health. He posted tirades on social media about the faculty at the Wyoming law school and sent harassing emails to police after getting a speeding ticket, authorities said.
University of Wyoming police began investigating Riehl last October after the social media posts, including a vague threat to shoot someone, The Denver Post reported. Riehl's brother told campus police that Matthew Riehl had been diagnosed with bipolar disorder.
By Nov. 14, university police were concerned enough to call Colorado authorities about Riehl, according to police in Lone Tree, Colorado, about 18 miles (25 miles) south of Denver.
On Sunday, Riehl dialed 911 and police responded to his apartment in Highlands Ranch, not far from Lone Tree. He opened fire, police said, killing Douglas County Deputy Zackari Parrish and wounding four other officers and two civilians.
Parrish's funeral will be Friday.
This article was written by Kathleen Foody and Dan Elliott from The Associated Press and was legally licensed through the NewsCred publisher network. Please direct all licensing questions to email@example.com.