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 in Riverside, about 10 miles 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.