Omar Mateen, the Orlando gunman, was investigated by the FBI for 10 months after telling work colleagues in 2013 that he was a member of Hizbollah and had family ties to al-Qaeda.
James Comey, the FBI director, said the agency interviewed Mateen, sent in undercover agents and trailed him during the investigation.
Mateen admitted that he had said he was affiliated with the terrorist groups, but maintained that he only made the comments "in anger" because he felt persecuted for being Muslim.
He was again investigated in 2014 after being linked to a man who became a suicide bomber in Syria. They attended the same mosque and knew each other, but the FBI determined that they had no significant relationship.
Mateen was placed on the FBI's terror watch list for the duration of the first investigation but never arrested.
He continued to work for G4S, the British security company which hired him in 2007, and to carry guns legally.
There were no shortage of red flags, according to Daniel Gilroy, one former colleague who described Mateen as racist, sexist, homophobic and frighteningly aggressive, adding: "I'm not surprised at what he did".
"Everything he said was toxic and the company wouldn't do anything," Mr Gilroy told Florida Today. "This guy was unhinged and unstable. He talked of killing people."
John Kenning, G4S's chief executive for North America, said internal screening in 2013 raised "nothing of concern", though the company was aware that he had been questioned by the FBI and that "the inquiries were subsequently closed". The company did not respond when asked whether his colleagues' concerns had reached managers. With no criminal record, Mateen passed the annual checks required to renew the firearms licence he needed as a security officer.
He was able to purchase an AR-15 style assault rifle and another gun
legally 12 days before the attack.
An FBI spokesman said an individual's inclusion on the terror watch list was kept confidential so as not to "impair the government's ability to investigate and counteract terrorism".
Members of Mateen's community were not alerted that the FBI considered him a possible threat. Syed Rahman, the imam at his mosque, said it "would have been helpful" to know that he might have been radicalised.
Dr Rahman said there were "rumours here and there that he was very aggressive", but Mateen had been unusually quiet in recent years, and had no close friends at the mosque.
Seddique Mir Mateen, the gunman's father, told reporters that, had he known his son was going to carry out an attack, "I would have arrested him myself". He has insisted his son was not radicalised.
"I don't know what made him [do this], I have no idea," he said in a clip posted on Facebook on Sunday night. "I had no idea that he felt resentful in his heart and had gone to the gay club and killed men and women there." He said his son should not have carried out the killings because "Allah himself will punish those involved in homosexuality, not his servants on earth".
Mr Mateen Snr, who moved to America during the Soviet-Afghan war, is a minor celebrity in Afghan political circles there, hosting an occasional television show. In some videos, posted on YouTube, he expresses support for the Afghan Taliban, who he describes as "our warrior brothers".
After watching the videos, Ahmad Mukhtar, an Afghan commentator, said it seemed possible that Mr Mateen was delusional.
"He thinks he runs a government in exile and will soon take the power in Kabul in a revolution," he noted.