WASHINGTON – The Supreme Court on Thursday struck down a federal law that makes it a crime to lie about being a military hero. In fact, the justices ruled that many lies are protected by the First Amendment.

The 6-3 ruling came in a case involving Xavier Alvarez, a former local elected official who at a 2007 water board meeting in Southern California falsely claimed that he had served as a Marine and received a Medal of Honor, the nation’s highest military decoration. As Justice Anthony M. Kennedy wrote for the majority, “Lying was his habit.”

The ruling is one of several recent Supreme Court rulings dealing with the First Amendment that would seem to go against public sentiment. As Justice Samuel Alito wrote in the dissenting opinion, the law was “enacted to stem an epidemic of false claims about military decorations” that “were undermining our country’s system of military honors and inflicting real harm on actual medal recipients and their families.”

The court’s majority opinion was that the law punishing the liars was more damaging than the lies.

“Permitting the government to decree this speech to be a criminal offense, whether shouted from the rooftops or made in a barely audible whisper, would endorse government authority to compile a list of subjects about which false statements are punishable,” Kennedy wrote. “That governmental power has no clear limiting principle.”

The ruling went on to suggest a less severe way to deal with those who lie about military glory: create a database that could be used to verify claims. A government database of all medal winners doesn’t exist, though there is a Medal of Honor database.

“Only a weak society needs government protection or intervention before it pursues its resolve to preserve the truth,” Kennedy wrote. “Truth needs neither handcuffs nor a badge for its vindication.”

Doug Sterner, a military historian from Alexandria, Va., was instrumental in getting Congress to pass the Stolen Valor Act, which was signed into law by President George W. Bush in 2006. Still, Sterner said he agreed with the court’s reasoning on creating a digital database. The Department of Defense has rejected the idea in the past, in part noting that a 1973 fire in St. Louis destroyed 18 million records, so such a database would be incomplete.

“There’s nothing I’d like to see more than a database, and (the Pentagon) knows all the records are in 500 boxes on paper cards. They could create a database in less than a year, and it wouldn’t cost that much to do it,” Sterner said.The law imposed prison sentences of up to six months on those who “falsely represent” that they have received any military “decoration or medal.” For certain elite medals, the penalty increased to a year in prison.

In this case, Alvarez pleaded guilty but reserved the opportunity to challenge the law as an infringement on First Amendment rights to free speech.

Roy Gutterman, who heads Syracuse University’s Tully Center for Free Speech, said the ruling was in line with other recent First Amendment decisions by the court, such as one protecting the right of a Topeka, Kan., pastor to protest near military funerals. Gutterman said Thursday’s ruling was poetic at points, and called a reference to George Orwell’s Ministry of Truth — in which the truth was altered to fit government needs in the novel “1984” — particularly poignant.

“What the court was saying is, ‘Where’s the real harm in the lie?’ at least versus sanctions that limit free speech,” Gutterman said. “There has to be a better way.”