The suspect was arrested by the FBI and members of the U.S. Capitol Police after a lengthy sting operation. Undercover FBI agents had posed as al Qaeda associates and provided the would-be bomber with the vest and MAC-10 machine gun. The suspect had allegedly been watched for more than a year and had indicated that he wanted to launch an attack.

The criminal complaint alleged that El Khalifi was angry because he thought the U.S. was conducting a "war on Muslims."

The government alleged that El Khalifi, a Moroccan citizen, entered the U.S. in June 1999 and stayed in the country illegally after his B2 visa expired later that year.

The FBI has been monitoring the man since January 2011. An FBI affidavit filed in court noted the case picked up intensity in December 2011, when El Khalifi allegedly met with an individual he knew as Hussien and another man who identified himself as Yusuf.

According to the FBI affidavit, Yusuf was an undercover law enforcement officer, but El Khalifi believed he was associated with al Qaeda.

The affidavit alleged that El Khalifi discussed with Yusuf and Hussien attacks against a U.S. military office in Virginia, the home of an Army general, a synagogue and a restaurant.

Last month, El Khalifi became focused on bombing the restaurant and Hussien allegedly told El Khalifi he was associated with al Qaeda. Hussien told El Khalifi other operatives would bomb a U.S. military installation after the restaurant bombing, according to the affidavit.

On Jan. 8, 2012, in preparation for the attack, El Khalifi allegedly purchased nails, two jackets and a cell phone for use in the attacks.

Days later, on Jan. 15, Hussien and El Khalifi allegedly traveled to a West Virginia quarry where El Khalifi tried on a jacket with an inert explosive and detonated a test bomb. On this trip, El Khalifi also allegedly decided that he would rather target the Capitol Building than the restaurant.

"El Khalifi told Hussien not to question his desire to do the attack. El Khalifi said he would be happy killing 30 people," an FBI affidavit filed in the case alleged.

The document also stated, "El Khalifi dialed a cell phone number that he believed would detonate a bomb placed in the quarry to see what the explosion would look like from a device similar to that which he planned to detonate at the United States Capitol Building. The test bomb detonated, and El Khalifi expressed a desire for a large explosion in his attack."

In late January and in early February, Hussien and El Khalifi allegedly conducted surveillance of the U.S. Capitol area to determine where to carry out the attack.

In their final planning meeting on Feb. 14, 2012, El Khalifi met with Yusuf and Hussien, and the would-be suicide bomber was given a MAC-10 machine gun that he had requested to shoot police officers if they tried to stop him from detonating his bomb, authorities alleged.

The men discussed al Qaeda's plans to attack the military target, an attack that was to have taken place after El Khalifi's bombing, according to officials. Hussien allegedly told El Khalifi that al Qaeda leaders intended to release a video about the attacks. El Khalifi told Hussien he did not want to be named but referred to as "Al Maghrabi" in the video.

The affidavit noted that on Friday morning, Yusuf and Hussien drove El Khalifi to a parking garage "in close proximity to the United States Capitol." The document alleged that El Khalifi donned the vest containing the inert bomb and the inoperable MAC-10.

"El Khalifi told Hussien and Yusuf that he intended to use the MAC-10 automatic weapon to shoot people before detonating the bomb," the affidavit said. "El Khalifi walked alone from the vehicle towards the United States Capitol."

Agents arrested him before he exited the parking garage.

The public was never in danger, law enforcement officials told ABC News. However, officials said, the case is a sobering reminder that there remains a threat of homegrown radicals, so-called lone wolves.

"This arrest was the culmination of a lengthy and extensive operation, during which the individual was closely and carefully monitored," said Sgt. Kimberly Schneider of the U.S. Capitol Police, who said the suspect was arrested "in the area" of the Capitol building.

"The U.S. Capitol Police was intimately involved in the investigation for the duration of the operation. At no time was the public or congressional community in any danger."

"We can confirm that there has been an arrest of a suspect in Washington, D.C., in connection with a terrorism investigation," said Department of Justice spokesman Dean Boyd.

"The arrest was the culmination of an undercover operation during which the suspect was closely monitored by law enforcement," Boyd said. "Explosives the suspect allegedly sought to use in connection with the plot had been rendered inoperable by law enforcement and posed no threat to the public. Additional information will be forthcoming at the appropriate time."

The FBI has carried out a number of undercover terrorism sting operations in the last several years, and this one, federal sources said, was in the same mold as those executed in the past.

A number of those would-be terrorists targeted locations in Washington, D.C.

For example, in September 2011, Rezwan Ferdaus, a U.S. citizen from Ashland, Mass., and a Northeastern University physics graduate, was nabbed in an elaborate FBI sting after he told undercover officers exactly how he planned to arm "small drone airplanes" with explosives in order to hit the Pentagon and U.S. Capitol building

In April 2011, Farooque Ahmed pleaded guilty for his role in conducting surveillance to case Metro stations in Arlington, Va., in what he believed would be an attack on four Metro stations, including the Pentagon station, in a plot to kill military personnel. Ahmed was also arrested in an FBI sting operation.