Matthew's conversations with the friend who'd reached out to him online were abruptly interrupted when he had a disquieting mental-health episode that April. During a night of heavy drinking, he started acting and talking erratically, saying things that frightened his father. Concerned for his son, Steve Llaneza called 911, and a fire truck was dispatched to his address on Largo Drive.

When first responders entered Steve's home, Matthew was so out of control they had to place him in a four-point restraint before transporting him to Santa Clara Valley Medical Center. Once there, he thrashed on a gurney and screamed at medical staff. He slammed his head against the emergency-room hallway wall and pressed his neck against the gurney's side rail in an attempt to choke himself. When officers questioned him, his responses were either cryptic or fantastical. He pointed to one officer's belt and told him he could build everything that was on it. He also warned, "Someday you are going to find me dead in the desert."

Police officers decided to place him in a mental-health hold, a 72-hour involuntary psychiatric hospitalization for individuals deemed a danger to themselves or others. While Matthew was in the hospital, a police officer's concern spurred Steve to search the Winnebago. He found a semiautomatic weapon along with several large-capacity magazines, which he turned over to the police. Legal in Arizona, possession of the assault weapon was a felony in California. And with three loaded magazines also in his possession, Matthew faced up to six years in prison.

Before Matthew was transferred to Santa Clara County Jail, clinicians at the hospital diagnosed him with bipolar disorder and paranoid psychosis. Although such diagnoses—especially in combination—spoke to a seriously ill young man, it was the first time Matthew had ever received them or any other mental-health assessments.

It was an alluring reward for someone who felt the vise tightening around his post-felony life... All he had to do was drive an SUV to a Bank of America branch, slip off to a remote location, and trigger an explosion that would turn the bank building into a heap of fiery rubble.

Because of a new punishment method in California known as split sentencing, Matthew would spend less than a year of his sentence in jail, while the rest would be served under a strict probationary period on the outside. When he was released, in November 2011, he quickly found himself staring down a gauntlet of money troubles: He owed thousands in restitution and attorney costs and had to pay a monthly probation fee, and he struggled to find work because of the newly minted felony on his record. As a result he mostly lived off food stamps and was forced to sell his Winnebago to pay his legal bills.

He moved in with his dad, scraping together whatever he could to pay rent and casting about for any job he could find. But even the temporary and under-the-table stuff he did before the arrest seemed to be drying up. There was no work out there, he realized, especially with a charge like mine. Eventually, though, he got a job at a local plumbing company, where he started flashing vents, installing pipes, and digging drainage ditches. Most importantly, he started earning a steady paycheck.

Over the next few months, Matthew grew close with his supervisor at the plumbing company. His boss picked Matthew up for work, gave him free food from a local restaurant, and found him side jobs to help him claw his way out of debt. While driving to and from plumbing jobs together, they talked about guns, and Matthew boasted that he could build a bomb "from scratch." The supervisor sometimes invited Matthew to join him at a local shooting range, but Matthew always declined, citing his probation. Matthew recalls his new supervisor often sharing his political views, too. The two men criticized America's role in the Middle East, and Matthew told him how he'd converted to Islam years earlier. They also occasionally spoke—in loose, vague generalities—about fighting overseas.

In late November, Matthew's supervisor set up an introduction between Matthew and an "adopted cousin" of his. This man claimed to have ties to the Taliban and mujahideen in Afghanistan. Matthew met the cousin for the first time at a mall near San Jose. There they began brainstorming how they might go about launching a terrorist attack.

Over the course of the next two months, Matthew and the man he'd just met clumsily deliberated over what that attack might look like. Matthew proposed bombing the Federal Reserve Bank in San Francisco. He eventually backed off that plan, though, because of the imposing level of security that would be protecting a federal building. He suggested that they instead target a Bank of America branch in northern California. Initially, the cousin disapproved of Matthew's ideas. Matthew recalls that he seemed to want them to plan an attack with a maximum number of civilian casualties—at one point he proposed they target a light-rail station during rush hour.