Carolyn Kaster, Associated Press
In this July 8, 2015, photo, FBI Director James Comey testifies during the Senate Judiciary Committee hearing on Capitol Hill in Washington. Comey says Dylann Roof, the gunman in the Charleston church massacre should not have been allowed to purchase the gun used in the attack, and on July 10 attributed the problem to incomplete and inaccurate paperwork related to an arrest of Roof weeks before the shooting.

WASHINGTON — The gunman charged in the Charleston, South Carolina, church massacre should not been allowed to purchase the weapon used in the attack, FBI Director James Comey said Friday as he outlined a series of missed opportunities and incomplete paperwork that allowed the transaction to take place.

The problem stemmed from an arrest of Dylann Roof in South Carolina weeks before the shooting in which police say he admitted to possessing illegal drugs.

Under federal rules, that admission alone should have been enough to disqualify him from an April gun purchase. But, Comey said, the FBI background check examiner who evaluated Roof's request to buy a gun never saw the arrest report because the wrong arresting agency was listed on the list rap sheet that she reviewed.

The transaction went through after three days because the examiner didn't have enough information to authorize or deny it.

"If she had seen that police report," Comey said, "that purchase would have been denied."

Comey said he learned about the problem on Thursday night and that FBI officials planned to meet Friday with relatives of the nine victims of last month's church shooting in Charleston. He said he had also directed an internal 30-day review into how the FBI uses criminal background checks in gun transactions.

His announcement came within hours of the Confederate flag's removal from the South Carolina Statehouse. Families of the victims attended the ceremony.

Follow Eric Tucker on Twitter at http://www.twitter.com/etuckerAP