Andy Coulson, David Cameron's former communications director and ex-editor of the News Of The World (NoTW), has been acquitted in his perjury trial over claims he lied about phone hacking.
Coulson, 47, was on trial in Edinburgh over claims he had lied during another perjury trial of ex-MSP Tommy Sheridan, who was convicted for lying during a separate libel case he brought against the now defunct tabloid.
But the judge, Lord Burns, threw the case against Coulson out, saying the prosecution had not demonstrated the alleged lie had affected the outcome of the Sheridan trial.
Coulson claimed during the 2010 trial that he had no knowledge of phone hacking.
But he was later sentenced to prison after being convicted last year of phone hacking in one of the longest and most complicated trials in English legal history.
The judge made the ruling on Monday but it could not be reported for 48 hours, while prosecutors decided whether or not to appeal the decision.
The decision relates to the definition of perjury in Scottish law.
A lie is only perjury in Scots law if it can affect verdict; but Crown did not rely on Coulson's evidence, so irrelevant.June 3, 2015
In essence: it was the wrong type of lie.June 3, 2015
"Not every lie amounts to perjury," Lord Burns told the jury, explaining why the case was being thrown out. "The lies were not relevant and did not amount to perjury. I therefore acquitted him."
In his judgment, he said: "I consider that the false evidence alleged in this indictment was not relevant evidence at the original trial and the charge of perjury in the indictment is irrelevant."
Speaking outside court, Coulson told reporters that his acquittal was "the right decision" and denied he had lied.
"I'm just delighted after four pretty testing years," he said. "My family have had a good day."
Freelance reporter James Doleman, who had been covering the trial, said the prosecution's case had appeared to be "open and shut case of perjury, a slam dunk".
He wrote: "A number of Coulson's friends and colleagues recommended he plead guilty to avoid the trauma of another trial.
"Yet in one of the greatest escapes in legal history Coulson walked free from court without the jury ever being given the chance to consider the evidence."
After the acquittal, the Crown Office, which oversees prosecutions in Scotland, said: "Andrew Coulson was a defence witness at the trial of Tommy Sheridan. He gave his evidence without objection as to relevancy.
"The Crown indicted Coulson on the basis that he lied during parts of his evidence, in particular that he had no knowledge of phone hacking.
"The trial judge in the Coulson trial, at the conclusion of the prosecution evidence, ruled that this evidence was irrelevant and therefore could not found the basis for a prosecution for perjury. This brings proceedings to an end."
Coulson resigned from NoTW in 2007 to become David Cameron's communications chief. He stood down from that role in 2011 as the phone hacking allegations continued to dog him, despite his denials he knew anything about it.