Texas church shooter Devin Patrick Kelley's history of domestic abuse barred him from legally buying guns, but he did so anyway because information about his crimes was never entered into a federal database used for background checks.
Kelley is just the latest recent U.S. mass shooter to amass weapons by exploiting lapses in the background check process or by taking advantage of limited weapons laws.
Others have obtained guns while undergoing mental health treatment or got their hands on weapons that were initially purchased legally.
A look at some recent mass shootings and how the attackers obtained their guns:
SUTHERLAND SPRINGS, TEXAS: 26 PEOPLE KILLED ON NOV. 5, 2017
Kelley purchased four guns, including the AR-15-style rifle and handguns found in and near the First Baptist Church, from federally licensed dealers in Texas and Colorado over the last four years.
The 26-year-old passed required background checks because the Air Force never informed the FBI about his criminal conduct -- an assault on his wife and her child that led to a court-martial, a year of confinement and a bad conduct discharge.
The latest news from around North Texas.
Military rules require that the information be shared.
A 1996 law bans people convicted of even a misdemeanor-level domestic violence offense from owning guns. Kelley was convicted at a court-martial for choking his then-wife and fracturing her son's skull in 2012.
LAS VEGAS: 58 PEOPLE KILLED ON OCT. 1, 2017
Stephen Paddock amassed the bulk of his arsenal over the span of a year, culminating with a purchase three days before he holed up in a room on the 32nd floor of the Mandalay Bay hotel and opened fire on a country music festival below.
Paddock purchased 33 of the 49 weapons found in the hotel room and at his homes in Mesquite and Reno, Nevada, between October 2016 and Sept. 28, 2017, according to the Bureau of Alcohol, Tobacco, Firearms and Explosives.
None of the purchases drew scrutiny because the 64-year-old Paddock passed all background checks. His gradual accumulation of weapons went undetected because federal law does not require licensed gun dealers to alert the government about rifle purchases.
Twelve of the semi-automatic rifles recovered by authorities were equipped with bump stocks, a device that allows them to fire repeatedly without pulling the trigger over and over.
ORLANDO, FLORIDA: 49 PEOPLE KILLED ON JUNE 12, 2016
Omar Mateen purchased an AR-15-style rifle and a handgun on separate days about a week before the attack from a licensed dealer near his home in Fort Pierce, Florida. The 29-year-old passed a background check and had two security licenses, one of which allowed him to be armed while on duty, according to Ed Henson, owner of the St. Lucie Shooting Center.
The FBI investigated Mateen in 2013 and 2014 after co-workers shared concerns about statements he had made concerning possible ties to terrorist groups. Neither inquiry led to criminal charges. Even if he had been placed on a terrorism watch list, Congress in 2015 rejected attempts to prevent people on the list from purchasing guns.
SAN BERNARDINO, CALIFORNIA: 14 PEOPLE KILLED ON DEC. 2, 2015
Syed Farook and his wife used weapons that the FBI said were legally purchased by his neighbor, Enrique Marquez, from a licensed dealer in 2011 and 2012.
Marquez, who pleaded guilty to charges he conspired to provide support to terrorists and made false statements to acquire a firearm, told investigators that Farook asked him to buy the weapons because he would draw less attention. At the time, the FBI said, the men were plotting to shoot up a community college and a highway.
ROSEBURG, OREGON: 10 PEOPLE KILLED ON OCT. 1, 2015
Christopher Harper-Mercer and his family members legally purchased the handguns and rifle he used in the Umpqua Community College shooting from a federally licensed gun dealer, according to the Bureau of Alcohol, Tobacco, Firearms and Explosives.
CHARLESTON, SOUTH CAROLINA: 9 PEOPLE KILLED ON JUNE 17, 2015
A drug arrest should have prevented Dylann Roof from purchasing the pistol authorities said he used at Emanuel AME Church, but a record-keeping error and background check delay allowed the transaction to go through.
The FBI said a background check examiner never saw the arrest report because the wrong arresting agency was listed in state criminal history records. After three days, the gun dealer was legally permitted to complete the transaction.
WASHINGTON, D.C.: 12 PEOPLE KILLED ON SEPT. 16, 2013
Aaron Alexis, a former reservist turned civilian contractor, passed state and federal background checks and legally purchased the pump-action shotgun used in the Washington Navy Yard shooting despite a history of violent outbursts and recent mental health treatment.
Alexis was accused of firing a gun in anger in Texas in 2004 and in Seattle in 2010, but was not prosecuted in either case. In 2011, he received an honorable discharge despite bouts of insubordination, disorderly conduct and unauthorized absences. None of that would have disqualified him from purchasing a weapon.
NEWTOWN, CONNECTICUT: 26 PEOPLE KILLED ON DEC. 14, 2012
Adam Lanza used his mother's weapons, including a .223-caliber semi-automatic rifle, in the massacre at Sandy Hook Elementary School. Lanza's mother, whom he fatally shot before going to the school, also purchased the ammunition, investigators said.
AURORA, COLORADO: 12 PEOPLE KILLED ON JULY 20, 2012
James Holmes was receiving psychiatric treatment when he passed required federal background checks and legally purchased the weapons he used in his movie theater assault.
As in the Navy Yard case, Holmes' treatment alone did not prevent him from buying guns. The purchases would have been blocked only if he had been legally declared a "mental defective" or committed to a mental institution.