Twenty-nine people sentenced after a power station protest at which an undercover police officer was working have had their convictions quashed.
Protesters boarded a freight train carrying coal to the Drax plant near Selby in North Yorkshire in June 2008.
The case against them involved undisclosed information gathered by undercover officer Mark Kennedy.
Court of Appeal judges quashed the convictions over a failure to disclose Mr Kennedy was working undercover.
The decision follows an announcement in 2012 by the then Director of Public Prosecutions that he had concerns over the safety of convictions.
The convictions were overturned by the Lord Chief Justice Lord Thomas, Mr Justice Simon and Mr Justice Irwin.
Lord Thomas said: "There was a complete and total failure, for reasons which remain unclear, to make a disclosure fundamental to the defence.
"In those circumstances, this court has no alternative but to quash the convictions."
Outside court, Beth Stratford, speaking on behalf of the 29, said: "We are pleased because this shines a light on the underhand tactics of the police and the Crown Prosecution Service in their policing of political movements.
"It underlines further the need for public independent inquiry into the use of political policing."
The Drax protest lasted 16 hours, causing delays to numerous freight and passenger services, and the clean-up operation cost Network Rail nearly £37,000.
Participants were sentenced at Leeds Crown Court in 2009 and 2010 for obstructing the railway.
They were charged with obstructing engines or carriages on railways, which is an offence under the Malicious Damage Act 1861.
Some were ordered to do 60 hours of unpaid work and others were given conditional discharges.
Speaking about Mr Kennedy's involvement, Lord Thomas said the undercover officer, who hired a van and transported activists to the site, kept a detailed record of what happened and made reports to his handler, who communicated them to senior West Yorkshire police officers.
He said: "None of that was disclosed at the trial or at any time prior to it."
The judge said his involvement was "either the fault of the police or someone at the CPS or possible counsel involved" and said each of those interviewed had "given a different account".
Lord Thomas said it could not be categorically stated that the event would or would not have happened without Mr Kennedy's involvement but if it had been disclosed, as it should, issues would have been raised before the trial as to whether there had been an abuse of process.
The judge asked counsel to prepare written submissions on the question of who should be responsible for the "substantial" legal costs incurred, to be decided later.
Questioning why the Ministry of Justice should foot the bill, he said: "This is a plain case of fault, either by the West Yorkshire Police or the CPS, so why shouldn't they pay?"
Mr Kennedy spent seven years undercover, infiltrating left-wing protest groups and travelling to 11 different countries on 40 occasions.
His actions undercover led to the collapse in 2011 of the case against six protesters accused of planning to invade the coal-fired Ratcliffe-on-Soar power station in Nottinghamshire and led to a review of police undercover tactics.