President Obama, speaking to reporters at the White House, said it appeared the attack was “an example of the kind of homegrown extremism that all of us have been concerned about,” with a gunman who was inspired by radical material he found online.

Even as American military forces and intelligence agencies attack the Islamic State and other extremist groups, Mr. Obama said, “one of the biggest challenges we are going to have is this kind of propaganda and perversions of Islam that you see generated on the internet.”

New information also emerged Monday on Mr. Mateen, including frightening statements he made three years ago to co-workers at a local courthouse about being tied to terrorism, and that the resulting F.B.I. investigation was extensive, lasting 10 months.

Image Omar Mateen Credit... via MySpace

“First he claimed family connections to Al Qaeda,” which, like the Islamic State, is a Sunni Muslim terrorist group, James Comey, the F.B.I. director, said Monday. “He also said he was a member of Hezbollah,” a Shiite group in conflict with Al Qaeda and the Islamic State.

“He said he hoped that law enforcement would raid his apartment and assault his wife and child so that he could martyr himself,” Mr. Comey said.

“Our investigation involved introducing confidential sources to him, recording conversations with him, following him, reviewing transactional records from his communications,” and searching government records for mentions of him, the director said. “We then interviewed him twice. He admitted making the statements his co-workers reported, but explained that he did it in anger because he thought his co-workers were discriminating against him and teasing him because he was Muslim.”