A federal judge on Tuesday overturned the 2006 conviction of a California man accused of training in a Pakistani terrorist camp and lying to the F.B.I. about it, undoing a case once heralded by federal prosecutors after the Sept. 11 attacks as a proactive victory against terrorism.

The man, Hamid Hayat, 35, was sentenced in 2007 to 24 years in prison. He had served more than 14 years before Tuesday’s decision.

Image Hamid Hayat Credit... Lodi Police Department, via Associated Press

In overturning Mr. Hayat’s conviction and sentence, Judge Garland E. Burrell Jr., of United States District Court in Sacramento, said that Mr. Hayat had not been adequately represented during his trial. His lawyer did not use testimony from several witnesses who could have provided a credible alibi for Mr. Hayat, the judge wrote in his order.