A divided federal appeals court ruled that a decades-old federal law indefinitely banning people committed to mental health treatment from owning a gun could violate the Second Amendment.

The Sixth U.S. Circuit Court of Appeals on Thursday revived a lawsuit filed by a Michigan man who failed a background check while attempting to buy a gun in 2011. Clifford C. Tyler had been committed to a mental institution 25 years earlier but since has received a clean bill of health.

Judge Julia Smith Gibbons, writing for the Sixth Circuit majority, said government lawyers offered compelling evidence for prohibiting people currently or recently suffering from mental illness from possessing a gun. That evidence included the 2007 Virginia Tech massacre, committed by a student whom a court had ordered into outpatient treatment.

But, she wrote, “none of the government’s evidence squarely answers the key question at the heart of this case: Is it reasonably necessary to forever bar all previously institutionalized persons from owning a firearm?”​

Mr. Tyler sued the U.S. attorney general and his local sheriff in Hillsdale County, Mich., in 2012, alleging that the Gun Control Act of 1968 effectively created a permanent ban on his Second Amendment rights. A federal trial court dismissed his lawsuit, and Mr. Tyler appealed to the Cincinnati-based Sixth Circuit.

The 1968 law bans convicted felons, habitual drug users and others from possessing a firearm, including anyone “who has been adjudicated as a mental defective or who has been committed to a mental institution” involuntarily.

The director of the Bureau of Alcohol, Tobacco, Firearms and Explosives is empowered to restore the rights of those who can demonstrate that they aren’t a danger to public safety and whose possession of a firearm wouldn’t be “contrary to the public interest.”

But Congress defunded the review program in the 1990s. Thirty-one states have created mechanisms to review applications by people seeking to have their rights restored, but Michigan, where Mr. Tyler lives, isn't one of them.

A probate court committed Mr. Tyler to as many as 30 days of inpatient treatment in 1986, after his wife of 23 years ran away with another man and depleted his finances, according to Thursday’s ruling. His daughters, fearing that he was a danger to himself, had contacted police.

After the episode, he returned to work and remarried.

Mr. Tyler’s 2012 psychological and substance-abuse evaluations showed no evidence of mental illness or issues with alcohol or drugs, according to the ruling. Mr. Tyler, now 74, tried to purchase a gun in 2011 but failed the FBI background check.

Click for more from The Wall Street Journal.