Apple may have taken on the fight of its life in standing up to the FBI, which is demanding that it help break into an iPhone used by one of the perpetrators in December’s San Bernardino mass shooting.

Apple has promised to fight a U.S. magistrate judge’s order Tuesday requiring it to assist the FBI, and legal experts say the case could go all the way up to the Supreme Court.

Apple needs to tread carefully, however. A divisive presidential election has further polarized the country around issues including how to respond to terrorists, and Apple needs to be careful the public doesn’t turn against it.

By refusing the court’s order, Apple is choosing to “protect a dead ISIS terrorist’s p‎rivacy over the security of the American people,” Senator Tom Cotton, an Arkansas Republican, said in a statement.

Despite the lofty rhetoric and whichever side you’re on, it’s a position Apple would certainly rather not be in.

If the order from U.S. Magistrate Judge Sheri Pym still stands after Apple’s appeal, the company can elevate the case through the courts. With the case involving privacy, national security and other major issues, the Supreme Court may be interested, some legal experts said.

Some cases take years to reach the nation’s highest court, but this one is likely to move faster because it’s related to a high-profile terrorism investigation, with the FBI possibly hunting for associates of the shooters.

“This is a particularly important case,” said Gregory Nojeim, a senior counsel with the Center for Democracy and Technology. “While sometimes these things fester and drag on, sometimes they move quickly because they’re important.”

Like Apple, the FBI could also appeal any judicial order that reverses Pym’s decision. And the FBI is likely to fight on, given that the December 2 mass shooting is a high-profile terrorism case, and that FBI Director James Comey has been raising alarms about smartphone encryption since late 2014.

The FBI wants Apple’s assistance to defeat an iPhone feature that erases the information on the phone after 10 unsuccessful password attempts. Pym gave Apple five days (view a PDF of the court order) to appeal if the company finds it “unreasonably burdensome.”

It’s clear Apple will appeal, after CEO Tim Cook said Pym’s order amounts to a request for Apple to “hack our own users.”

“The U.S. government has asked us for something we simply do not have, and something we consider too dangerous to create,” Cook said in a statement. “They have asked us to build a backdoor to the iPhone.”

The next steps

If Pym’s order still stands, Apple could take it next to a district court judge. If it loses there, it could move to an appeals court, where it would likely be heard by a three-judge panel. If the company loses again, it could appeal the case to the full appeals court or the Supreme Court.

Apple will appeal immediately to a district judge if it loses a second time before Pym, Kevin Bankston, director of the New America Foundation’s Open Technology Institute, said by email. “Their need to comply [with the order] would almost certainly be stayed pending that appeal, and likely stayed pending a circuit appeal if that happened.”

Although legal experts say it’s unlikely, Pym could hold Apple in contempt of court if the company refuses to cooperate with her order. She could potentially impose “significant” fines, said Braden Perry, a regulatory and government investigations lawyer with the Kennyhertz Perry law firm in Kansas City. Fines could accrue while the company refuses to comply.

Contempt of court penalties also can include prison time, but most legal experts dismissed that possibility.

The judge’s order has ratcheted up a long-simmering debate about encryption and law enforcement access to personal information on smartphones.

On the other side of the debate to Senator Cotton, digital rights group Fight for the Future is planning nationwide protests at Apple Stores in opposition of the court order. The FBI’s request is a “dangerous demand” that will endanger the privacy of all smartphone users, said Evan Greer, Fight for the Future’s campaign director.

To comment on this article and other PCWorld content, visit our Facebook page or our Twitter feed.