“Last September, FBI was sent a screenshot of a comment by nikolas cruz,” Ann Coulter, the conservative commentator, said in a post on Twitter. “Unfortunately, the FBI was busy running down Clinton campaign leads about a nonexistent Russian conspiracy with Trump.”

It is not the first time that the F.B.I. has come under fire for being aware of a threat and failing to stop an attack.

Congress criticized the bureau for not preventing the 2009 mass shooting at Fort Hood in Texas, in which the gunman was known to the F.B.I. The bureau also knew of one of the two brothers who carried out the Boston Marathon bombing in 2013. And Omar Mateen, who killed 49 people in an Orlando, Fla., nightclub in 2016, had been investigated by the F.B.I. for months before the attack. That case was closed before the shooting occurred.

After those incidents, F.B.I. investigators compared themselves to hockey goalies, fielding a relentless barrage of pucks. Sometimes, they said, they could not keep things from making the net.

“The public expects the F.B.I. to keep them safe, and in the overwhelming majority of the instances, the F.B.I. does just that,” said Lauren C. Anderson, a former top F.B.I. official in New York.

The F.B.I. was not the only law enforcement agency to be warned about Mr. Cruz. Sheriff Scott Israel of Broward County said Friday that his office had received about 20 calls regarding the suspected school gunman over the past few years.

Sheriff Israel said on Friday that his office was still reviewing what it knew about Mr. Cruz before the shooting.