Former News Of The World (NotW) editor Andy Coulson has been cleared committing perjury after the case against him collapsed.
Coulson, a former director of communications for Prime Minister David Cameron, was accused of lying under oath during the 2010 trial of former MSP Tommy Sheridan.
The 47-year-old was accused of falsely claiming to be unaware that NotW private investigator Glenn Mulcaire and journalist Clive Goodman were involved in phone hacking until their arrest in 2006.
The judge at the High Court in Edinburgh has now thrown out the charges against Coulson after the defence team argued there was no case to answer for.
Coulson's team said when the former editor appeared as a witness at Sheridan's trial, the alleged lies he gave were not relevant to the trial of the former Scottish Socialist Party leader and therefore not relevant to his perjury trial.
Sheridan was convicted of lying under oath during the 2010 defamation trial against the NotW after it reported he visited a swingers' club.
During the trial, Coulson was called up as a witness and asked about his knowledge of hacking at the now-defunct paper. The case against him came about after he said he was not aware of a culture of hacking at the paper.
In 2014, Coulson was found guilty at the Old Bailey of conspiracy to hack phones when he was editor of the NotW, but maintained he was only ever aware of one incident.
However, defence advocate Murdo MacLeod QC argued Coulson's evidence was not relevant for Sheridan's conviction and therefore cannot be prosecuted for perjury under Scottish court law.
Explaining the decision to drop the case to the jury, Judge Lord Burns said: "Perjury is the wilful giving of false evidence under oath or affirmation in judicial proceedings. An oath or affirmation binds the witness to tell the truth.
"If he gives evidence in a criminal trial or in civil proceedings which he knows to be false and which was relevant to the issues in that trial or civil proceedings, he is guilty of perjury. Relevant means relevant either in proof of the charge against the accused in that trial or in relation to the credibility of the witness.
"Unlike the falsity of the evidence, the question of its relevance is a matter of law and therefore for the judge to decide on that matter and not the jury."
The ruling can only be reported now after the prosecution was given 48 hours to decide whether to launch an appeal against the decision.
Outside the court, Coulson said: "This prosecution was always wrong. I didn't lie. The prosecution in my view was a gross waste of public money.
"I'm just delighted after four pretty testing years my family and myself have finally had a good day."
A Crown Office spokesperson 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."