RIVERSIDE, Calif. -- The man accused of buying the assault rifles his longtime friend used in the San Bernardino massacre is a danger to the community and will remain in custody as he faces a terrorism-related charge, a judge ruled Monday.

Enrique Marquez, 24, appeared before U.S. Magistrate Judge David Bristow in federal court, about 10 miles (16 kilometres) from the site of the Dec. 2 attack that was carried out by Syed Farook and Farook's wife, Tashfeen Malik.

Marquez's court-appointed public defender, Young Kim, asked a judge to release his client on bond, saying he had voluntarily spoken to the FBI over a 10-day period while he was free to leave at any time.

Kim said the terrorism charge stemmed from unrealized plans by Marquez and Farook to attack a college and a congested freeway in 2011 and 2012.

"Those attacks never happened," Kim said. "That terrorism charge has nothing to do with the events in San Bernardino on Dec. 2."

The judge disagreed.

"The defendant actively conspired with the decedent, Mr. Farook, for purposes of participating in a terrorist act in this nation," Bristow said, adding that Marquez obtained two guns under false pretenses and obtained smokeless powder that Farook used to create improvised explosive devices.

"He continues to present that danger to the community," Bristow said.

Assistant U.S. Attorney Chris Grigg said Marquez did nothing to stop Farook from carrying out the San Bernardino attack, including trying to get the guns back.

No evidence has shown that Marquez participated in the Dec. 2 attack, but "nevertheless the plotting was real, the arming of Mr. Farook happened, and the San Bernardino shooting happened," Grigg said.

"No amount of bail can protect the community," he added.

The judge agreed that Marquez poses a threat but found that he wasn't a flight risk because he has spent his whole life in Southern California, has no criminal history, and his family was willing to put up $100,000 in equity on their home for bail.

Kim declined to comment after the hearing.

Marquez is charged with conspiring to provide material support to terrorists in abandoned plans for attacks in 2011 and 2012.

The count stems from plans Marquez had with Farook to use pipe bombs and guns to kill people at the college they attended and those stuck in rush-hour traffic on a California freeway, prosecutors said in court documents. The plots fizzled, and they never acted.

Marquez also is charged with illegally buying the rifles the shooters used in the San Bernardino attack and visa fraud stemming from his marriage to a Russian woman that prosecutors say was a sham.

Marquez could face up to 35 years in prison if convicted of all the charges.

Marquez's mother has called him a good person who was nothing more than friends with the man who carried out the massacre with his wife.

Farook and his wife, Tashfeen Malik, used guns that Marquez bought years ago to kill 14 people at an annual training of Farook's health department co-workers, authorities say. The couple later died in a shootout with law enforcement.