Four protesters charged with felonies for turning off emergency shut-off valves on two Enbridge Energy oil pipelines can use the threat of climate change as a defense for their actions, the state Court of Appeals ruled Monday.

The appellate court allowed the so-called "necessity" defense to go forward. In a pretrial hearing in District Court, the protesters testified about their "individual perceptions of the necessity of their actions in preventing environmental harm caused by the use of fossil fuels, particularly the tar sands oil carried by the pipeline with which they interfered."

The state objected to the defense, and the appeals court, on a 2-1 vote, has now dismissed that objection. The state can ask the Supreme Court to take up the issue.

The Court of Appeals didn't rule on whether the defendants' actions were necessary but said the state failed to show that allowing the defense would significantly reduce the likelihood of a successful prosecution. The court said state law doesn't allow objections to the necessity defense before trial.

The protesters charged in this case are Annette Klapstein, Emily Nesbitt Johnston, Steven Liptay and Benjamin Joldersma. The first three were charged with felony damage to property, aiding and abetting felony damage and gross misdemeanor trespassing. Joldersma was charged with conspiracy. Liptay recorded the actions in October 2016.

In a pretrial ruling, Clearwater County District Judge Robert Tiffany allowed the defense but said the necessity evidence must be "focused, direct, and presented in a noncumulative manner." The state argued that the necessity defense would "unnecessarily confuse the jury."

Judge Jill Flaskamp Halbrooks wrote the Appeals Court opinion also signed by Judge Denise Reilly. Judge Francis Connolly dissented.

"This case is about whether [defendants] have committed the crimes of damage to property and trespass. It is not about global warming," Connolly wrote.

The defendants have said they intend to call expert witnesses to testify about global warming and their belief the federal government's response has been ineffective.

Connolly's dissent cited a 1971 state court ruling that said the necessity defense "applies only in emergency situations where the peril is instant, overwhelming, and leaves no alternative but the conduct in question." The defendants in this case cannot meet that requirement, Connolly wrote.

The protesters were part of an effort by Climate Direct Action to shut down five pipelines carrying tar sands crude from Canada to Minnesota, North Dakota, Montana and Washington.

The charges carry maximum terms of more than 20 years in prison, though prosecutors have said the most likely penalty is up to a year in jail.