The FBI is investigating whether Syed Rizwan Farook and the former neighbor who bought the guns used in a deadly shooting intended to commit an act of terror in about 2012 and then got spooked, a senior law enforcement official said Wednesday.

The two men might have been disrupted when the FBI arrested several men in late 2012 for a separate plot to kill Americans in Afghanistan.

Farook and his wife - who killed 14 people in San Bernardino, Calif., last week - were discussing jihad at least two years before they opened fire, FBI Director James Comey said Wednesday in addition to the comments of the official, who spoke on the condition of anonymity because details of the case remain secret.

The husband-and-wife duo "were radicalized for quite a long time before their attack," Comey reiterated during an appearance on Capitol Hill in front of the Senate Judiciary Committee. This follows earlier statements by investigators that both shooters had been adherents to a radical strain of Islam long before the massacre.

Farook, a 28-year-old county health inspector, and his Pakistani wife, Tashfeen Malik, 29, had begun communicating online, Comey said. It was during these communications that they began discussing jihadist thoughts, long before Malik traveled to the United States and they got married.

"And online . . . as early as the end as 2013, they were talking to each other about jihad and martyrdom before they became engaged and then married and lived together in the United States," Comey said during his testimony.

This radicalization appears to predate the rise of the Islamic State, the terrorist group that in 2014 formally declared a caliphate in parts of Iraq and Syria.

Comey said investigators believe the attackers were "inspired by foreign terrorist organizations."

"We're working very hard to understand exactly their association and the source of their inspiration," he said. "We're also working very hard to understand whether there was anybody else involved with assisting them, with supporting them, with equipping them."

When asked by Sen. Lindsey Graham (R., S.C.), a presidential candidate, if the marriage between Malik and Farook was arranged by a terrorist organization, Comey said he did not know.

"It would be a very important thing to know," Comey said. He also said he was not aware of any Islamic State cells operating in the United States.

Comey was critical of anti-Muslim rhetoric, saying that it is not helpful when law enforcement officials are trying to work with communities in the United States to combat terrorism. He said that for the Islamic State and other terrorist organizations, it is part of their strategy to convince Muslims that the United States is hostile to them.

The GOP presidential front-runner, Donald Trump, drew international criticism this week for his call to ban all Muslims from the United States after the San Bernardino shooting and the attacks in Paris last month.

The FBI is trying to determine whether there is any connection between an earlier potential plot by Farook and his former neighbor, Enrique Marquez, and the arrests in 2012 of four men in Riverside, Calif. The men were charged with plotting to kill Americans in Afghanistan. Two of the men were later found guilty, and two pleaded guilty.

Marquez provided the military-grade rifles used during the San Bernardino attack. He legally purchased the rifles - semiautomatic AR-15s manufactured by DPMS and Smith & Wesson - in California, officials said. The FBI is still investigating whether Marquez sold these rifles to Farook, according to the officials, who also spoke on the condition of anonymity for similar reasons.

Comey said Wednesday that there was an attempt to convert the rifles into fully automatic weapons before the attack.

Farook brought his wife to the United States on a fiancee visa in July 2014.

Relatively little is known about Malik, who was born in Pakistan but spent at least some time in Saudi Arabia, where her father relocated more than two decades ago. She is also known to have studied in Pakistan to become a pharmacist.