A car carrying Enrique Marquez Jr. arrives at U.S. District Court in Riverside, California, on Thursday.

The friend of one of the San Bernardino shooters was arrested Thursday and charged with conspiring to commit terrorism and illegally purchasing two assault rifles used in the attack that killed 14 people.

Enrique Marquez, 24, purchased the two assault rifles that his friend and former neighbor, Syed Rizwan Farook, used along with his wife, Tashfeen Malik, to carry out the Dec. 2 terror attack.

Included in the three-count criminal complaint filed on Thursday are charges that Marquez defrauded immigration authorities by entering into a sham marriage with a member of Farook’s family.

Authorities allege Marquez and Syed Rizwan Farook had planned attacks in Southern California back in 2011, including using firearms and explosives to attack the Riverside City College. They also allegedly planned to bring a portion of the 91 Freeway to a halt during rush hour using pipe bombs, and then open fire on stuck motorists and responding authorities.

The two men went so far as purchasing firearms, ammunition, and other tactical gear, as well as practicing at local firing ranges, according to the complaint.

In late 2011 and 2012, Marquez bought firearms on two occasions from a sporting goods store, but authorities allege the weapons were actually for Farook to carry out the attack.

The two also reviewed Inspire magazine, written by supporters of al-Qaeda in the Arabian Peninsula, to design and construct pipe bombs with Christmas tree lights to remotely detonate, Marquez told agents, according to the complaint.

While the alleged plots never came to fruition, FBI bomb technicians found that much of what Marquez and Farook learned while they planned their attacks was later used in the San Bernardino shooting.

The indictment also revealed details of Marquez's relationship with Farook and how it evolved over time.

According to the federal complaint, the two met in 2004 in Riverside, California, as next-door neighbors. After Farook introduced Marquez to Islam, he converted in 2007.

Federal investigators allege Farook then began introducing him to radical Islamic ideology, including lectures by Anwar al-Aulaqi, an American and Yemeni imam who was suspected of being involved with and recruiting for al-Qaeda. He and his son were killed by U.S. drone strikes.

Despite the alleged conspiracies to commit domestic terrorism, authorities say Marquez and Farook started losing contact with each other in 2013, which was around the time four men from Southern California were arrested on suspicion of plotting to travel to Afghanistan and attack U.S. soldiers.

The dispatcher, assuming they might have misheard, asked again if his friend died in the shooting.

"He was the shooter," he repeated. "The fucking asshole used my gun in the shooting."

Marquez also quickly checked into a local mental health facility. Days later, federal investigators raided his home, tore apart his garage door with blowtorches, and questioned family members for hours.

Marquez had been cooperating with the San Bernardino investigation, but officials had hinted that his arrest was imminent.