Federal agents who sought to interview a man later charged in connection with the San Bernardino terror attack were not even allowed to enter a U.S. Citizenship and Immigration Services office where he was slated to be questioned a day after the massacre, stunned lawmakers were told at a hearing Tuesday.

On Dec. 3, 2015, just one day after Syed Farook and Tashfeen Malik murdered 14 people and injured 22 others at a Christmas office party in the Southern California community, the FBI learned that Enrique Marquez, a friend of Farook’s suspected of supplying the assault rifles used in the terrorist attack, was scheduled for an interview at the San Bernardino USCIS office. The FBI asked Immigration and Customs Enforcement agents to intercept Marquez at the facility, but when the ICE agents arrived, they were denied entry, as well as access to Marquez’s file.

Details of the turf battle were revealed at a Senate Committee on Homeland Security and Governmental Affairs hearing Tuesday, when Senate Chairman Ron Johnson, R-Wis., questioned directors of both USCIS and ICE.

“This is the kind of mistake that can get people killed."

- Jessica Vaughan, Center for Immigration Studies

“How can you explain that they would not let Homeland Security agents in the building when they are saying, ‘Listen you could have a potential terrorist here involved in what just happened yesterday in the slaughter of 14 Americans?’” an incredulous Johnson asked. “And they don’t even allow them in the office? How could that have possibly happened?”

USCIS Director Leon Rodriguez replied that the agency operates “under certain protocols” and that the administrator in charge of the San Bernardino office checked with his superiors but somehow screwed up anyway.

“The guidance was to facilitate what Homeland Security Investigations was trying to accomplish. Unfortunately, it all happened so quickly that it was incorrectly perceived that our folks were trying to obstruct what ICE was trying to do,” said Rodriguez. “Do we need to look at our protocols to make sure this is something that does not occur? It may well be something we need to do. But there was never an actual intent to prevent them from doing what they needed to do.”

ICE Director Sarah Saldana said she was initially concerned when her agents were blocked, but told lawmakers there was “confusion” and “chaos” in San Bernardino the day after the attack.

“We had immediate conversations when it came to my attention,” she said. “It was taken care of and clarified immediately. We did get the information we needed.

“We can always do things better, and if we don’t, as I tell my son, learn from the mistakes we make, then shame on us,” she added.

Johnson, who learned of the situation from a letter sent to his committee, said it exposes a “potential breakdown of agencies cooperating.”

“I find it pretty disconcerting to say the least,” Johnson said. “Putting myself in the position of the USCIS, if I had the day after a terrorist attack, I had a team, armed, coming into my office and saying, ‘We believe somebody who is involved in that terrorist attack is in your building, we want to come in,’ I would say, ‘Come on in.’ There would not have been a question in my mind, and yet that is not what happened. It is quite puzzling.”

USCIS agents were investigating Marquez for marriage fraud, stemming from his 2014 union with Mariya Chernykh, a Russian national married to Farook’s brother. Marquez, who is now in jail and awaiting trial this summer, is accused of supplying the guns as well as marriage fraud.

The incident reveals how federal immigration agencies are increasingly hostile to the mission of homeland security, said Jessica Vaughan, director of policy studies for the Center for Immigration Studies, a Washington-based research institute.

“I was completely flabbergasted to hear that USCIS managers had obstructed ICE agents in the midst of an urgent terror investigation – one that was the worst terror attack since the Boston Marathon bombing,” Vaughan said after watching the hearing. ”I cannot imagine any possible excuse for USCIS to block agents from their sister homeland security agency from making an arrest in a federal building during a terror investigation, nor can there be any good reason to deny them access to the files.

“This is the kind of mistake that can get people killed, and someone needs to be held accountable for this egregious behavior,” Vaughan added.

Both Farook and Malik were killed by law enforcement after their morning attack. Marquez is accused of making false statements in connection with his weapons purchases used in the San Bernardino shooting. Prosecutors also have alleged that Marquez and Farook plotted in 2011 and 2012 to carry out attacks at Riverside City College and on the 91 Freeway.

Marquez has pleaded not guilty to the charges filed against him. If convicted of all counts, Marquez faces up to 50 years in prison.