In this April 2006 court sketch, terror probe defendant Hamid Hayat, right, and his attorney Wazhma Mojaddidi listen to the judges verdict at a courthouse in Sacramento. (Vicki Ellen Behringer/AP)

It was a month after 9/11, and Osama bin Laden’s face flashed across the news on Naseem Khan’s TV screen.

The FBI was sitting in his living room in Bend, Ore., and Khan sensed an opportunity. The agents had come for an entirely different purpose and were ready to leave — until Khan pointed at the screen and said he thought he could help with something else. A few years ago, he said, he saw bin Laden’s second-in-command, Ayman al-Zawahiri, one of the most wanted terrorists in the world, at a mosque in the wine-country town of Lodi, Calif.

The agents perked up, intrigued by the possibility. Had they really just stumbled into a hot tip on al-Qaeda while speaking to a 28-year-old McDonald’s worker and convenience store clerk? The FBI thought Khan was onto something — a possible “sleeper cell” of terrorism hidden in Lodi ― and decided to dispatch him there as a confidential informant.

Khan wouldn’t find any associates of Zawahiri at the mosque in Lodi, and U.S. officials and terrorism experts now doubt his initial claim about Zawahiri was ever true. But Khan would find 19-year-old Hamid Hayat — who would soon become the face of homegrown terrorism in post-9/11 America.

They met at the mosque, and Khan learned Hayat was taking a trip to Pakistan with family. Over and over, in recorded conversations, he returned to the same question: Would Hayat commit to attending a terrorist training camp, as he had promised?

Now, a judge’s order on Tuesday casts doubt on whether Hayat ever actually did.

Hayat, a cherry-picker and son of an ice cream truck driver, was convicted of attending the alleged terrorist training camp and sentenced to 24 years in prison in 2006. Prosecutors, relying on Khan and Hayat’s own statements, alleged that he attended the camp for three to six months sometime in 2003. The case would become one of the most high-profile examples of the government’s fight against terrorism in the immediate aftermath of 9/11, especially because Hayat, after hours of interrogation by FBI agents, confessed to attending the camp.

But on Tuesday, U.S. District Judge Garland E. Burrell Jr. vacated his conviction and sentence, finding that Hayat had inadequate defense during the 2006 trial while casting doubt on the facts of the case. Burrell questioned whether jurors would have convicted him had they heard evidence from witnesses in Pakistan, which the judge said likely would have “undermined” jurors’ confidence in Hayat’s confession alone. His attorneys have maintained the confession was coerced during an exhausting interrogation.

Had the defense attorney actually interviewed any witnesses in Pakistan who spent significant time with Hayat during his trip, she would have discovered that they recalled Hayat spent most of his time playing video games and cricket and that the purpose of his visit was for his family to find him a wife, according to Burrell’s order. No one identified any prolonged disappearance that would have allowed him to visit a terrorist training camp for three to six months as prosecutors alleged and Hayat said in the confession, Burrell noted. Burrell, who oversaw Hayat’s original trial, found the witnesses gave consistent statements and could have provided Hayat a credible alibi.

“Showing that Hayat could not have been at a jihadi training camp for the ‘period of months’ specified in the indictment would have been completely consistent with the defense that Hayat’s confession should not be credited and the government lacked other supporting evidence,” a U.S. magistrate wrote in making the recommendation that Hayat’s conviction be vacated. Burrell adopted most of the magistrate’s findings of fact.

The government has not decided yet whether to appeal the decision, a spokeswoman in the U.S. attorney’s office in the Eastern District of California said in a statement, the Sacramento Bee reported. “We are in the process of reviewing the district court decision and assessing what steps, if any, should be taken and considering all our options,” the statement said.

Hayat, now 36, is currently being held in a federal prison in Phoenix. His attorneys are seeking his immediate release.

The case against Hayat and his father, Umer, who was accused of lying to the FBI, heaped international attention on the Northern California town of Lodi. Seemingly overnight, the town went from the zinfandel capital of the world to an alleged terrorism “sleeper cell” — a claim authorities would later walk back.

At the time he met Khan in August 2002, Hayat lived in his parents’ garage and didn’t have many friends, as the Intercept recounted in a 2016 investigation. Posing as a radical Islamist, Khan nudged Hayat into conversations that were anti-American and supportive of Islamic fundamentalist groups, and to his delight Hayat went along with it, according to recorded conversations cited in federal court documents. Hayat approved of the beheading of Wall Street Journal journalist Daniel Pearl by Pakistani militants. He told Khan he believed jihadists had attended his grandfather’s religious school in Pakistan and claimed his grandfather was so politically well connected that the Pakistani president enlisted him in efforts to persuade the Taliban to turn over bin Laden after 9/11.

Then came the terrorist camps. Hayat said he had seen one in an online video — and expressed interest in going himself. Khan, feeding the intel to the FBI, egged him on.

But once in Pakistan, Hayat kept making excuses, according to the judge’s order. When Khan told him he was being “lazy,” Hayat claimed the climate had changed and it got too hot outside — the terrorist camp was canceled, he said. Khan was starting to get mad. His nudges turned to threats.

“God willing, when I come to Pakistan and I see you, I’m going to ... force you to, get you from your throat and ... throw you in the madrassa,” Khan said in one expletive-laden recorded conversation, as the Intercept reported.

“I’m not going to go with that,” Hayat said.

“Oh yeah, you will go,” Khan told him. “Yeah, you will go. You know what? Maybe I can’t fight with you in America, but I can beat your a-- in Pakistan, so nobody’s going to come to your rescue.”

In their last conversation, according to the Intercept, which obtained all the recordings, Hayat said he “never intended on going to a camp.”

Hayat denied attending a camp in his first interview with the FBI in Japan, before flying to San Francisco. He confessed during his second interview in California upon his return in June 2005.

“FBI: Al Qaeda plot possibly uncovered,” rang a CNN headline in June 2005, saying those involved “Trained on how to kill Americans.”

Months after Hayat’s arrest, then-director of national intelligence, John D. Negroponte, testified in a congressional hearing that a “network of Islamic extremists in Lodi, Calif., for example, maintained connections with Pakistani militant groups, recruited United States citizens.”

But ultimately, no other terrorism cases arose from the investigation except for the one against Hayat. Two imams were investigated but were never criminally charged with anything. They had overstayed religious worker visas, authorities discovered.

A retired FBI agent who watched Hayat’s interrogation and the resulting confession told the Los Angeles Times it was “the sorriest interrogation, the sorriest confession, I’ve ever seen,” believing the agents fed Hayat the details they wanted to hear and that Hayat repeated them so he could leave. He was barred from offering his testimony at trial. Burrell found that the failure to challenge the validity of the confession by presenting a false confession expert also contributed to his finding that Hayat had ineffective counsel.

Khan was ultimately paid nearly $230,000 for assisting the FBI over three years. During Hayat’s trial, his defense attorney questioned how one fast-food worker’s implausible claim that he saw the world’s most wanted terrorist in a small-town mosque could have “sparked this whole investigation with this ridiculous claim,” the Times reported in 2006.

Hayat’s attorneys filed an appeal in 2014 and ultimately sought to interview numerous witnesses in Pakistan who could account for his whereabouts during the trip from 2003 to 2005. They appeared for sworn depositions on video in 2018. When Hayat’s attorney, Dennis Riordan, asked his uncle whether he “would have known” if Hayat disappeared from their rural hamlet, Muhammad Anas said, “Naturally, I would have noticed,” the Marshall Project reported then.

The judge found that the witnesses “corroborated each other on some important points,” regarding trips the family took throughout Pakistan and who they visited. Once or twice a month, they traveled to a hospital for his mother’s medical treatment.

On Tuesday, Hayat’s family issued a statement applauding the judge’s decision to throw out Hayat’s conviction, the Sacramento Bee reported.

“We have been waiting 14 long years for Hamid to be freed,” the statement read. “Hamid cannot get those 14 years of his life back, but we are relieved to see the case take such a big step forward. We miss him and hope to be reunited with him soon.”