A woman wears tributes to Rev. Sharonda Singleton and Ethel Lance during a memorial service remembering the victims of the mass shooting at Emanuel African Methodist Episcopal Church in Charleston, S.C. (Sean Rayford/Getty Images)

The families of victims killed in last year’s shooting at the Emanuel AME Church in Charleston, S.C., are suing the FBI over an error during a background check that allowed the alleged shooter to buy his gun.

The lawsuit comes a year after the mass shooting that sent shock waves through the country. Dylann Roof, then 21, a white high school dropout, is charged with opening fire and killing nine black parishioners during a prayer meeting at the historic African American church.

In the days after the shooting, FBI Director James B. Comey said in a remarkable disclosure that Roof shouldn’t have been able to buy the gun he allegedly used.

Roof had been arrested for possession of narcotics in February 2015, a charge that alone did not disqualify him from buying a gun. But Comey said Roof’s subsequent admission of the drug crime would have triggered an automatic rejection of his gun purchase if the information had been properly recorded in ­criminal-record and background-check databases.

Authorities have said that a clerk’s mistake in how Roof’s arrest was listed prevented the FBI examiner for his background check from seeing it. And once the three-day mandatory waiting period for gun purchases expired, Roof was able to buy the .45-caliber Glock handgun.

“We are all sick this happened,” Comey said at the time. “We wish we could turn back time.”

In one of the multiple lawsuits filed Thursday, the victims’ families said, “If the gun sale was denied as required, it would have prevented the foreseeable harm to those people.”

Attorney Andrew Savage said, “The victims and families hope that by bringing these actions, they can shine a very bright light on these shortcomings and prevent other individuals, families and communities from dealing with unfathomable and preventable loss and injury.” Savage is representing three survivors of the attack as well as the relatives of five victims who were killed.

“It’s beyond a clerical error,” said S. Randall Hood, an attorney representing the wife of the Rev. Clementa Pinckney, who was also killed in the shooting. If federal agencies are going to be in control of who is allowed to buy guns, he said, “they need to do it right.”

Roof’s federal trial is scheduled to begin in November; his state trial is also set for later this year but is likely to be rescheduled. He faces the death penalty in both cases.

Two weeks ago, to mark the anniversary of the shooting, family members of the victims and survivors gathered at Emanuel Church to commemorate those killed and talk about the acts of forgiveness, grace and love they have experienced in the past year.

“The incident has left many persons searching for a personal way to respond and counteract the hate and negativity that was the basis for the act,” the church said in a message for the event on its website, adding this quote from the Bible: “Let all that you do be done in love.”