A federal appeals court ruled Friday that a lawsuit against the federal government over a faulty background check that let a South Carolina man buy the handgun he later used to kill nine people at a historically black church in Charleston can go forward.

The Fourth Circuit U.S. Court of Appeals overturned a lower court ruling that found the government was immune from liability because the claims brought by survivors and relatives of people killed in the June 2015 massacre did not fit into narrow exceptions to laws that shield public employees from liability while carrying out their official duties.

The panel found that an examiner who conducted a background check on Dylann Roof failed to follow a mandatory procedure when she did not contact police in Columbia, S.C., about his arrest on a drug possession charge weeks earlier.

ROBBER SHOOTS SOUTH CAROLINA CHURCHGOER DURING SERVICE, COPS SAY

"Once the examiner's inquiry revealed that the Columbia PD was the arresting agency and that it had the report, she was required to contact it. Her decision not to do so involved no permissible exercise of discretion," Judge Roger Gregory wrote for the federal panel in Friday's ruling, adding, "The government can claim no immunity in these circumstances."

After the shooting, then-FBI Director James Comey said Roof had been able to purchase the Glock 41 handgun “only because of lapses in the FBI’s National Instant Criminal Background Check System (NICS),” according to court documents.

SOUTH CAROLINA MAN, 90, CHARGED WITH MURDERING 83-YEAR-OLD WIFE

“Dylann Roof, the alleged killer of so many innocent people at the Emanuel A.M.E. Church, should not have been allowed to purchase the gun he allegedly used that evening,” Comey said at the time. (In late 2016, a jury found Roof guilty in the church massacre, and he was subsequently sentenced to death.)

CLICK HERE TO GET THE FOX NEWS APP

U.S. District Court Judge Richard Gergel said last year the FBI’s background check process was “disturbingly superficial,” pointing to multiple clerical errors and mistakes.

The Associated Press contributed to this story.