Phil Haney, a founding member of the Department of Homeland Security, has claimed work he was carrying out in 2012 could have stopped the San Bernardino terror attack

A founding member of Department of Homeland Security says a database he spent years creating could have helped stop the San Bernardino terror attack, before it was destroyed by federal officials.

Phil Haney, who investigated terror groups in the wake of 9/11, claims he investigated two groups with links to terror killers Syed Farook and Tashfeen Malik as far back as 2012.

If he had been allowed to continue his probe, he claims, it would have flagged the pair to the security services, and may have stopped them killing 14 people and injuring 21 in California last week.

However, he says government civil rights officials destroyed the information he collected over fears he was unfairly profiling Muslims, investigated him, and then stripped him of his security clearance.

Speaking with Fox News on Thursday night, Haney explained that in the early 2000s he had been working in a passenger analysis unit at the Department of Homeland Security in Atlanta.

As part of his job, he was expected to investigate individuals and organizations with potential links to terrorism, so security services could monitor their movements into and out of the U.S.

Haney explained that he began investigating dozens of individuals with links to a fundamentalist Pakistani group called the Deobandi Movement, and its sub-groups al-Huda and Tablighi Jamaat.

He claims the groups were using the visa waiver program to move suspected radicalized individuals in and out of the U.S. and so he began tracking them, entering their details into a DHS database.

Eventually, his efforts were picked up by the National Targeting Center, an umbrella organization within the US Customs and Border Protection, and he was asked to work for them instead - focusing specifically on Deobandi, al-Huda and Tablighi Jamaat.

Haney says that, during the course of his investigation, he was given an award for identifying more than 300 potential terrorists with links to the groups.

Haney (picturd while at the DHS) says a database he was building into groups with links to terror would 'very plausibly' have led to Syed Farook being placed on a no-fly list, and Tashfeen Malik being denied a U.S. visa

During the course of his probe, Haney raised a red flag over the Darul Uloom Mosque in Riverside, California, as it was one of a several mosques worldwide operating under the umbrella of Deobandi.

Syed Farook later attended the same mosque, which has now been identified in FBI investigations following the San Bernardino killings.

Meanwhile, Farook's wife was known to associate with the al-Huda group in Pakistan, which was also flagged by Haney, he claims.

Haney believes that, if his program had been allowed to continue, both Farook and Malik would 'very plausibly' have been flagged to the security services over their connections to these organizations.

He told Fox: 'Either Syed would have been put on the no-fly list because of his association with that mosque, and or the K-1 visa that his wife was given may have been denied because of his affiliation with a known organization.'

However, in 2012, Haney says that his team was paid a visit by the Department of State and its own Civil Liberties Civil Rights Division.

Haney says officials accused of unfairly profiling Muslims because Tablighi Jamaat, the sub-group of Deobandi, was not on a list of specially designated terrorist organizations.

Haney claims that these measures would have stopped Farook and Malik from launching their attack on a regional center in San Bernardino which saw 14 people killed and another 21 injured

Haney says he left the national center shortly afterwards and went back to Atlanta, and afterwards he found out the program he was working on had been shut down.

Not only that, but large parts of the database that he had worked for years to assemble - 67 records in total - were removed from the security service databases, he claims.

The Department of Homeland Security accused Haney of having 'several large holes' in his story this evening, but said it was prevented from saying anything else because of privacy laws.

Haney's allegations came as Representative Matt Salmon, a Republican from Arizona, accused intelligence services of 'failure' for not picking up Farook or Malik before they launched their attack on the Inland Regional Center on December 2.

In 2012 a group of suspected terror plotters were arrested in California, along with Sohiel Kabir, a terror recruiter and mastermind of the plot, located in Afghanistan.

CNN reported that two security sources confirmed Farook had links to Kabir.

According to an unnamed Reuters security source, Farook and Malik’s names likely arose during an earlier FBI investigation but didn’t raise any flags - though it is unclear if this was related to the 2012 arrests.