Mohammed Atif Siddique will remain in custody until 9 February
Appeal Court judges have overturned the conviction of a man branded a "wannabe suicide bomber" by prosecutors.
Mohammed Atif Siddique, 24, a student from Alva, Clackmannanshire, was convicted of terrorism charges in 2007.
But Lord Osborne said some directions given to the jury by the trial judge were a "material misdirection" and amounted to a "miscarriage of justice".
Siddique will remain in custody until 9 February, when the Crown will say if it wants to seek a fresh prosecution.
The shopkeeper's son was convicted in October 2007 after a four-week trial in Glasgow.
He was found guilty of two charges under the Terrorism Act 2000, one under the Terrorism Act 2006 and a breach of the peace.
The most serious charge related to the possession of articles that gave rise to "reasonable suspicion" they were connected to terrorism.
The jury found Siddique had amassed and distributed terrorist propaganda via websites and provided instructional material about guns and explosives over the internet.
His conviction on that allegation resulted in a six-year prison term.
The Crown Office will indicate at the next hearing in February if it wants to seek a fresh prosecution in relation to the terror charge.
A spokeswoman said: "We note the decision of the appeal court and will be considering the judgement."
Giving the appeal judges' decision, Lord Osborne criticised the way the trial judge explained the main Terrorist Act charge to the jury.
The judge, sitting with Lords Reed and Clarke in Edinburgh, said the misdirection amounted to "a miscarriage of justice".
His family has always insisted he was not a terrorist and was made a scapegoat by the legal system.
Siddique also protested his innocence throughout, claiming that when he downloaded material from the internet he was motivated only by curiosity. He denied he was planning a terrorist attack.
During his appeal hearing last summer, defence lawyers argued that much of the material in his possession was widely available on the internet.
Defence QC Donald Findlay described the Terrorism Acts as "draconian" and advocate depute Derek Ogg QC, for the Crown, admitted that the legislation was "controversial".
The charges followed Siddique's arrest in April 2006 as he waited to board a plane to Pakistan.
Siddique's lawyer Aamer Anwar said he would be making no comment until after the conclusion of the proceedings on 9 February.