The man who bought the assault rifles his friend used in the San Bernardino massacre will remain in custody as he faces terrorism-related allegations because he is a danger to the community, a judge has ruled.

Enrique Marquez, 24, yesterday appeared before US Magistrate Judge David Bristow in federal court, about 16 kilometers from the attack carried out by longtime friend Syed Farook and Farook's wife.

"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 got two weapons under false pretenses and obtained smokeless powder that Farook used to create improvised explosive devices.

"The grave threat presented to the community by that conspiracy was demonstrated on December 2 when Mr Farook and his wife committed a terrorist act on the Inland Regional Center. ... He continues to present that danger to the community," Bristow said.

But the judge found that Marquez didn't pose a flight risk because he has spent his 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.

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 say in court documents. The plots fizzled, and they never acted.

Marquez also is charged with illegally buying the rifles the shooters used in the attack and visa fraud stemming from his marriage to a Russian woman that prosecutors say was a sham. He faces up to 35 years in prison if convicted of all the charges.

His court-appointed attorney has declined to comment. 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 on December 2, authorities say. The couple later died in a shootout with law enforcement.