The duo, who had become adherents to radicalized Islam ideology as neighbors in Riverside, wanted to maximize carnage by using pipe bombs and guns to kill innocent people at a campus cafeteria and those stuck in rush hour traffic, court documents said.

Those plans may never have come to light if not for the attack where Farook and his wife, Tashfeen Malik, used guns Marquez bought years ago to kill 14 people and wound 22 at a holiday meeting of Farook's health department co-workers.

Marquez was charged with illegally purchasing the rifles that the shooters used in the slaughter and were found with hours later after dying in a gunbattle with police.

In his initial court appearance, Marquez looked disheveled. His short hair flopped over his forehead, there was stubble on his face, and the pockets of his black pants were turned out. He appeared calm and showed no emotion as he gave one-word answers to the judge.

Less than a month before his friend carried out the San Bernardino massacre, the man who bought the assault rifles used in the attack wondered when the multiple lives he was leading would come crashing down.

"Involved in terrorist plots, drugs, anti-social behavior, marriage, might go to prison for fraud, etc," Enrique Marquez Jr. told someone in a Nov. 5 chat on Facebook described in a court document that foreshadowed the trouble he was facing before any bullets started flying.

Now he stands accused of terrorism-related charges and other counts that connect him to the the San Bernardino attack.

Marquez, 24, was charged Thursday with conspiring to provide material support to terrorists in deadly plots with Syed Rizwan Farook in 2011 and 2012 that they never carried out.

Here's video of Enrique Marquez arriving to federal court in Riverside. Marquez is the friend who bought the assault...

No plea was entered and he was ordered held until a bail hearing Monday in U.S. District Court. If convicted of all three counts, he could face up to 35 years in federal prison.

His public defender declined comment, though friends and family have described him as a good person who was easygoing and liked to party.

Marquez, a former licensed security guard, was working at a Riverside bar at the time of the shooting and is not alleged to have had a role in the attack.

But prosecutors said he was linked to the killings by the guns and explosive materials he bought years earlier. The couple used that material in a remote-controlled pipe bomb that never detonated at the conference room where the shootings occurred.

A lengthy affidavit by FBI special agent Joel Anderson outlines evidence against Marquez, including statements he gave investigators over 11 days after he waived his rights to remain silent and be represented by a lawyer.

Attorney E. Martin Estrada, a former federal prosecutor in Los Angeles, said the admissibility of Marquez's statements to the FBI will likely be challenged by defense lawyers, but if the statements are allowed in court, they give prosecutors a very strong case because of corroborating evidence.

"This wasn't a conversation with an average Joe," Estrada said. "This was a conversation with a person that was capable and had the capacity and the intent to commit mass murder. That's pretty chilling."

The affidavit said Marquez called 911 hours after the attack to say his neighbor had used his gun in the shooting, using an expletive to describe Farook.

Marquez then showed up agitated at a hospital emergency room, saying he had downed nine beers and was "involved" in the shooting. He was involuntarily committed to a psychiatric ward.

Marquez lived next door to Farook, 28, who introduced him to Islam 10 years ago. Marquez told authorities he converted to Islam around age 16 and four years later was spending most of his time at Farook's home, reading, listening to and watching "radical Islamic content" that included al-Qaida instructions on how to make bombs.

Four years ago, Marquez said, he and Farook planned to toss pipe bombs into the cafeteria at Riverside Community College and then shoot people as they fled.

They also planned to throw pipe bombs on a busy section of freeway that has no exits, bringing traffic to a halt and then picking off motorists. Marquez would shoot from a nearby hillside, targeting police, as Farook fired at drivers from the road.

As part of the plan, Marquez bought two assault rifles — in November 2011 and February 2012. He said he agreed to buy them because "Farook looked Middle Eastern."

Authorities previously said Marquez had legally purchased the guns Farook and Malik used. But the charges allege that Marquez lied by signing paperwork that said the guns were for himself or a family member.

The FBI has said Farook and Malik, 29, were radicalized before they met online in 2013, but the court documents show Farook had turned down the path to violent plots much earlier.

Marquez said he and Farook aborted their plans after authorities interrupted a terror plot in the area in November 2012 that involved four men who wanted to join either the Taliban or al-Qaida fighting U.S. forces overseas.

He said they didn't see much of each other after it unraveled, though he deepened his connection with the Farook family, marrying the Russian sister of the wife of Farook's brother last year.

Prosecutors said it was a sham marriage to help the woman obtain U.S. residency.

According to the affidavit, Marquez was paid $200 per month for the union and said his own mother and brother didn't know about it.

When his mother visited him at the hospital two days later after the shootings, her son again referred to Syed Rizwan Farook by an expletive and said he did not know "he was going to do that," Anderson said in the affidavit. Marquez also said he no longer wanted Farook as a friend.

You’ve probably seen many courtroom stories on TV and rightly assumed that reporters went into the courtroom, sat down with pen and pad, made notes and went out to their cameras and told their stories.

More times than not, that’s exactly what happens, but not in the case of Enrique Marquez.

In this case, reporters were directed to a third floor courtroom and then after a lengthy wait, we were sent down to a second floor courtroom. We stood in line there for quite awhile actually. Then our electronic devices were checked to be sure they were in the off mode. Once inside, we saw a television monitor displaying the courtroom we had just left with Marquez at the defense table.

There was a lot of security in the building. He was handcuffed and shackled, but never seemed nervous or upset.

Actually, he seemed very calm. But reporters with deadlines might have felt differently.

The 24-year-old Marquez has been on the FBI’s hot seat since the attack. According to court documents, Marquez spent ten days talking to the feds. Each day he would waive his rights and tell the story of how he met shooter Syed Farook in 2004, and in the years that followed, was radicalized by his next door neighbor and friend.

According to investigators the two planned, but never carried out, attacks on Riverside Community College and the 91 Freeway.

The complaint is long and detailed. But in short, he’s back in court Monday for a bail hearing in a case in which he is accused of providing material support in the San Bernardino terrorist attack.