SAN BERNARDINO, Calif. — Enrique Marquez Jr., who bought the assault rifles used in a terrorist attack that killed 14 people this month, was charged Thursday with conspiring to carry out two other attacks in 2012, federal officials said.

Marquez and Syed Rizwan Farook, one of the shooters on Dec. 2, had planned to attack other targets in Southern California, including a nearby community college and highway, according to a criminal complaint.

The documents provide the clearest look yet not only of Marquez but also of Farook, who died in a shootout with police after the massacre. Farook was interested in violent extremism at least two years before he and his future wife, Tashfeen Malik, corresponded online about waging violent jihad, according to Marquez’s account to the government.

The charges against Marquez are the first to stem from the investigation into the massacre, the worst terrorist attack on U.S. soil since Sept. 11, 2001.

The FBI arrested Marquez, 24, and he made his first court appearance in Riverside, Calif., later in the day. Marquez, who had not been seen since becoming the focus of the investigation, appeared in a beige T-shirt, handcuffed and with a chain around his waist. He seemed relaxed, leaning back in his chair, and said he understood the charges against him. He answered “Yes” when asked whether he had read the complaint and understood it.

Farook and Marquez never attempted to carry out their earlier plans, but their plotting reached a high level of detail.

In their plan to attack Route 91, a heavily trafficked road that runs through the heart of Riverside, the two men first considered throwing pipe bombs into the road to stop traffic, the FBI alleges. Authorities say they even scoped out a hill where one could watch for approaching law enforcement after the bombs exploded while the other moved among the stopped vehicles, firing into cars and killing motorists.

In another plot, the men discussed going to Riverside City College, a community college both had attended, and throwing pipe bombs into the cafeteria before attacking another location.

Authorities also said that in addition to buying the guns used by the husband-and-wife attackers, Marquez bought explosive material later used to construct the pipe bomb that authorities found at the Inland Regional Center after the mass shooting.

The most serious charges pertain to the earlier plots from 2012 rather than the San Bernardino shooting. But Marquez was also charged with making a false statement in connection with the acquisition of firearms used in that attack.

“While there currently is no evidence that Mr. Marquez participated in the Dec. 2, 2015, attack or had advance knowledge of it, his prior purchase of the firearms and ongoing failure to warn authorities about Farook’s intent to commit mass murder had fatal consequences,” U.S. Attorney Eileen M. Decker of the Central District of California said in a statement.

The complaint also states that hours after the shooting, Marquez called 911 to report that Farook, his former neighbor, had used his gun in the attack.

“My neighbor. He did the San Bernardino shooting,” Marquez told the 911 operator. “The f—ing asshole used my gun in the shooting.”

The government document shows Farook as clearly being the force guiding Marquez toward violent extremism.

After Marquez moved to Riverside, his next-door neighbor introduced him to Islam. By 2007, Marquez had converted to the religion and Farook began educating him about the views of Anwar al-Awlaki, the U.S.-born imam and Islamist lecturer who inspired numerous terrorist attacks and was killed in a 2011 drone strike. The two men read al-Qaeda’s English-language Inspire magazine, which has published directions for building bombs, and watched videos promoting violent extremism.

Marquez bought two assault rifles for Farook — one in November 2011, the other in February 2012 — with the intention of using them in these attacks, he told investigators. Marquez went on to sign forms stating that he was buying them for himself, but the government alleges they were a straw purchase.

Both guns were recovered at the scene of the firefight between police officers and Farook and Malik, and investigators say they were used in the attack at the Inland Regional Center earlier that day.

In 2012, Marquez also bought smokeless powder for making explosives as part of the earlier plot, the complaint alleges, and the powder — along with other materials for making explosive devices — was found in Farook’s home after the shooting. Authorities also say that Marquez confirmed to investigators this month that the powder bottle was the same one he had purchased three years earlier, and officials say the powder was the same one found in the pipe bomb at the center.

Marquez told investigators that he stopped plotting with Farook and distanced himself from him after a terrorism investigation in Riverside ended with four local men arrested in November 2012 for plotting to kill Americans in Afghanistan. The men were later convicted and sentenced to prison. On Wednesday, FBI Director James B. Comey said there was no evidence that Farook had any connections to those men and authorities have not found any ties among Farook, Malik and any other organizations.

The complaint also states that on the morning of the attack here, Malik searched social media for the Islamic State, the extremist group also known as ISIS or ISIL. Sixteen minutes after “at least one individual” opened fire inside and outside the Inland Regional Center, Malik posted a pledge of allegiance to the self-proclaimed emir of the Islamic State.

Law enforcement officials searched Marquez’s home three days after the shooting. The day after the shooting, Marquez went to the UCLA Harbor Medical Center emergency room and told workers there that he drank nine beers before arriving. He was referred to the psychiatric ward and placed on an involuntary hold there.

After the FBI tracked him down, he waived his right to have an attorney present, the complaint states.

Two days before his home in Riverside was raided, Marquez posted a garbled message on Facebook: “I’m. Very sorry sguys. It was a pleasure.” The next day, when he didn’t show up for his job as a doorman at a pirate-themed neighborhood bar, his co-workers began to worry that he may have become suicidal.

Marquez and Farook were also connected through a marriage that authorities now allege was a sham. Last year, Marquez married Mariya Chernykh, and her sister, Tatiana, is married to Farook’s brother, a Navy veteran named Syed Raheel Farook.

The complaint states that Marquez was paid $200 a month for the marriage and that he lied on government forms by claiming that he lived with his wife.

One official said the FBI had sought to determine whether Marquez was “grandstanding” during his interviews with the FBI, adding that agents were trying to corroborate his statements and see if he was a reliable “narrator” of the time he spent with Farook.

Marquez’s family has declined multiple requests for interviews, but his mother, Armida Chacon, briefly talked to reporters last week. She became distraught as she described her son as “a good person.”

Berman and Goldman reported from Washington. Ellen Nakashima, Lindsey Bever, Joel Achenbach and Julie Tate contributed to this report.