WASHINGTON — Three hours before two gunmen opened fire outside a Prophet Muhammad cartoon contest in Garland, Tex., the F.B.I. sent a bulletin to the Garland police warning them that one of the men might show up at the event, the F.B.I. director, James B. Comey, said Thursday.

“We developed information just hours before the event that Simpson might be interested in going to Garland,” Mr. Comey told reporters at a news briefing, referring to Elton Simpson, 30, who carried out the attack on Sunday night with Nadir Soofi, 34, also of Phoenix. Mr. Comey said he did not believe that the officers in the security detail outside the event were aware of the bulletin.

One school security guard was shot in the leg before a traffic police officer killed both gunmen. Mr. Comey praised the traffic officer, who he said, “under fire, remained calm and returned fire in an appropriate way.”

The F.B.I., which investigated Mr. Simpson from 2006 to 2014, reopened its investigation in March when he began to post messages on Twitter about the Islamic State. Mr. Comey’s disclosure on Thursday underscored how close the authorities came to heading off the attack.