Under federal law, the F.B.I. has three business days to determine whether there is sufficient evidence to deny a purchase. If the bureau cannot come up with an answer, the purchaser can return to the dealer on the fourth day and buy the gun.

Many major gun retailers, like Walmart, will not sell a weapon if they do not have an answer from the F.B.I., because of the fear of public criticism if the gun is used in a crime. The marginal sale of one gun means little to the bottom line of a large dealer, which is not the case for smaller stores like the one that sold Mr. Roof his gun.

Two days after Mr. Roof tried to buy the weapon, an examiner at the F.B.I.’s national background check center in Clarksburg, W.Va., began investigating his criminal history. The examiner found that Mr. Roof had been arrested this year on a felony drug charge, but not convicted. The charge alone would not have prevented him from buying the gun under federal law. But evidence that Mr. Roof had been convicted of a felony or was a drug addict would have resulted in a denial, so she continued to investigate his background.

Because Mr. Roof had been arrested in a small part of Columbia that is in Lexington County and not in Richland County, where most of the city is, the examiner was confused about which police department to call. She ultimately did not find the right department and failed to obtain the police report. Had the examiner gained access to the police report, she would have seen that Mr. Roof had admitted to having been in possession of a controlled substance and she would have issued a denial.

The examiner, however, did send a request to the Lexington County prosecutor’s office, which had charged him, inquiring about the case. The prosecutor’s office, however, did not respond.

Around that time the three-day waiting period expired, and Mr. Roof returned to the store and purchased the gun.

Mr. Comey said that he had spoken with the examiner, who he said had been working in that position for several years, adding that she was “heartbroken.”