Enrique Marquez, accused in the San Bernardino attack, is shown appearing for his arraignment in federal court in this sketch from Riverside, Calif. (Mona Edwards/Reuters)

The Department of Homeland Security was created from 22 federal agencies the year after the Sept. 11, 2001, terrorist attacks to create a “unified, integrated department” for “a more secure America.”

But a terrorist attack 14 years later showed that more work needs to be done before that description is fully realized.

Following the Dec. 2 attack in San Bernardino, Calif., three DHS agencies collided and demonstrated just how far from unified and integrated the department was during that emergency situation. The direct result of this episode was more inconvenience than calamitous, but what it said about the department’s ability to respond efficiently and rapidly is chilling.

Here is the story as outlined by DHS Inspector General John Roth in a report issued last week.

First, the cast of characters:

Immigration and Customs Enforcement (ICE)

Homeland Security Investigations (HSI, part of ICE)

U.S. Citizenship and Immigration Services (USCIS)

Federal Protective Service (FSP)

Department of Homeland Security (DHS).

The day after the attack that left 14 dead and 22 wounded, ICE learned that Enrique Marquez, who authorities say purchased the weapons used by shooters Syed Farook and Tashfeen Malik, might be at a USCIS office in San Bernardino. The office was protected by private security guards under contract to FPS. These alphabet soup agencies all are part of DHS.

Five HSI agents, decked out in tactical gear, rushed to the office to prevent any further attacks and to detain Marquez and his wife for questioning.

Yet despite the urgency, coming less than 24 hours after the attack, “the FPS guards advised the HSI agents that they had to stay in the lobby until the Field Office Director approved their entry.”

At first, the guards couldn’t find the director because she didn’t answer her phone. Once located, she didn’t want to allow the agents into the building. In true bureaucratic fashion, the field office director said she had to check with her boss, the district director in Los Angeles, who then checked with a higher boss, the regional director in Laguna Niguel, Calif.

The district director instructed the field office director to allow the agents into the building “to determine what they wanted.” Then they waited.

“[T]he agents were confined to the lobby for approximately 15 to 20 minutes,” they told the inspector general’s office. More than enough time for any suspect to get away.

Imagine five cops anxious to take down a terrorist waiting in the lobby for permission to go further into the building before they could search for him.

After the initial wait, “the agents were escorted to a USCIS conference room by FPS guards, where they met with the Field Office Director,” the inspector general’s report said. “According to the HSI agents’ accounts, they waited approximately 10 additional minutes in the conference room before the Field Office Director met with them. The agents told her they were looking for Marquez because he was connected to the shootings and there was concern that he could be in the building.”

The field office director’s response?

Roth said “the Field Office Director told the agents they were not allowed to arrest, detain, or interview anyone in the building based on USCIS policy, and that she would need to obtain guidance from her superior before allowing them access.”

The field office director again called the district director who notified the regional director, who notified an associate director in Washington, who met with USCIS lawyers. The report supplies names for none of these people.

Meanwhile, the field office staff determined that neither Marquez nor his wife was at the office.

The agents then asked for information about Marquez from the USCIS file, but the field office director refused. She did provide a photo.

At some point, the associate director determined that the agents could have the file. That information was relayed back down the chain, to the regional director, then to the district director, then to the field office director. More than an hour after arriving, an agent hand-copied information from the file and the law enforcement officers left.

Roth’s conclusion: “The contract security personnel at the facility should have immediately permitted entry to the HSI agents once they identified themselves and explained their official purpose.”

The department’s response: “ICE and USCIS have since improved their protocols for facility access and information sharing in circumstances with potential national security or public safety implications, in order to avoid any such delays in the future.”   FPS also is “clarifying” its “policy of allowing law enforcement partners access to federal facilities during emergency situations.”

That statement leaves many questions unanswered about what Sen. Ron Johnson (R-Wis.), chairman of the Senate Homeland Security and Governmental Affairs Committee, called “a dangerous lack of coordination …

“The refusal to allow armed ICE agents into a USCIS facility to detain a suspected terrorist could have had tragic consequences.”

Read more:

[Prosecutors say San Bernardino attacker’s friend had ties to group arrested for 2012 terror plot]

[Enrique Marquez tells his awful and pathetic story]

[Homeland chief keeps trying to make his employees happy]