A Minnesota judge abruptly dismissed charges against three climate change activists during their trial on Tuesday, saying prosecutors had failed to prove that the protesters’ attempt to shut down two Enbridge Energy oil pipelines caused any damage.

The Clearwater county district judge Robert Tiffany threw the case out after prosecutors rested their case and before the protesters could use their defense: that the threat of climate change from using crude oil drilled from Canadian tar sands was so imminent that the activists’ actions were not only morally right, but necessary.

The attorneys had long fought to use a “necessity defense” during the trial of the three Seattle-area residents, two of whom admitted turning the emergency shut-off valves on the northwest Minnesota pipelines in 2016 as part of a coordinated action in four states. Such a defense has been used by other activists protesting against pipelines.

Their attorney, Lauren Regan, acknowledged outside the courthouse in Bagley that she and her clients were surprised that the judge had granted their motion to dismiss the case. The three defendants faced felony charges involving criminal damage to critical public service facilities. They could have faced up to a year in jail, according to prosecutors.

“I’m very relieved the state of Minnesota acknowledged that we did no damage and intended to do no damage,” the defendant, Emily Johnston, said. “I also admit that I am disappointed that we did not get to put on the trial that we hoped for.”

The Clearwater county attorney, Alan Rogalla, declined to comment afterward.

Climate change activists have increasingly turned to direct actions against oil and gas pipelines, with mixed legal success . Valve-turner cases in other states resulted in convictions that are under appeal. A Massachusetts judge in March cleared 13 gas pipeline protesters who used a necessity defense. While the cases generally have not set binding legal precedents, activists are hoping they help legitimize direct action as a tactic against climate change.

In the Minnesota case, Johnston and Annette Klapstein readily acknowledged turning the emergency shut-off valves on two Enbridge Energy pipelines on 11 October 2016, near Leonard, about 210 miles north-west of Minneapolis. A third defendant, Ben Joldersma, called in a warning to Enbridge. Charges were earlier dropped against a fourth defendant.

They did it as part of a coordinated action by Climate Direct Action activists to shut down five Canadian tar sands crude pipelines in Minnesota, North Dakota, Montana and Washington state. A total of 11 activists were charged in the four states.

The Calgary, Alberta-based Enbridge temporarily shut down the two pipelines as a precaution before any damage occurred. The company issued a statement Tuesday saying the protest was “reckless and dangerous”.

“The individuals involved in these activities claimed to be protecting the environment, but they did the opposite and put the environment and the safety of people at risk – including themselves, first responders and neighboring communities and landowners,” the company said.

The defendants insisted there was never any danger.

“We did everything in our power to make sure this was a safe action, and we did this to protect our children and all of your children from the devastating effects of climate change,” Klaptstein said at the activists’ news conference afterward.

The valve turners had hoped to put climate change itself on trial by presenting expert witnesses who would have backed up their claims that climate change was making natural disasters worse, and that the threat of climate change from Canadian tar sands crude – which generates more climate-damaging carbon dioxide than other forms of oil – was so imminent that they had no legal alternatives. But they never got the chance.