A federal judge in Pennsylvania issued a ruling Tuesday reviving the lawsuit of a state trooper fighting for his Second Amendment rights.

U.S. Middle District Judge John E. Jones III said the outcome of a similar lawsuit forced him to reconsider Michael Keyes’s case, which he dismissed last year because a Superior Court determined Keyes’s history of mental illness could not be expunged, therefore precluding him from the right to bear arms.

Keyes lost his “private capacity firearm rights” a decade ago when an “emotionally devastating” divorce left him suicidal and depressed, according to court documents. The 25-year state police veteran was involuntarily committed at a local hospital for two weeks in August and September 2006 and then released from treatment.

Keyes spent the next four years fighting to return to his job as a state trooper — in which he carries a pistol daily and arms himself with a semiautomatic rifle and shotgun while on patrol — before securing victory and $16,000 in back pay.

However, his petition for relief from federal firearm disabilities lacked “an established mechanism” in Pennsylvania, leaving him “without recourse to challenge the loss of private gun rights under federal law,” Jones wrote in court documents Tuesday.

State and federal laws bar individuals with a history of mental instability from legally buying guns, though Keyes argues “one isolated incident” shouldn’t disqualify him from private ownership.

Keyes filed documents in state Superior Court in 2012 requesting an expungement of his involuntary commitment, but the judge ruled it was an inappropriate request beyond the court’s reach. Jones upheld that decision in November 2015.

Meanwhile, Jonathan K. Yox, a state prison corrections officer and Army veteran, who signed on as a co-plaintiff in Keyes’s original suit filed last year, appealed Jones’s decision.

Yox was involuntarily committed as a teenager for suicidal tendencies, but went on to join the military and deploy to Afghanistan. He was never recommended for further psychological evaluation, PennLive reports.

In July, Jones ruled in favor of Yox and reinstated his full private ownership rights.

Jones notes both Keyes and Yox “were adjudged by the Pennsylvania state court to no longer pose a risk to themselves or others due to mental illness and were thus relieved of their firearm disabilities,” and said the only difference in the cases was Keyes originally “filed in the wrong court.”

“He is left with no recourse to receive vindication of his constitutional right to bear arms, even though this Court has, for all material purposes, made clear that his claim has full merit,” Jones said. “This is a grossly unfair and inequitable result.”

Keyes and his attorneys have 10 days to schedule new trial terms, court documents show.