The Supreme Court on Thursday struck down a federal law making it a crime to lie about receiving the Medal of Honor and other prized military awards, with justices branding the false claim "contemptible" but nonetheless protected by the First Amendment.

The court voted 6-3 in favor of Xavier Alvarez, a former local elected official in California who falsely said he was a decorated war veteran and had pleaded guilty to violating the 2006 law, known as the Stolen Valor Act. The law, enacted when the U.S. was at war in Afghanistan and Iraq, was aimed at people making phony claims of heroism in battle.

The ruling, written by Justice Anthony Kennedy, ordered that the conviction be thrown out.

"Though few might find respondent's statements anything but contemptible, his right to make those statements is protected by the Constitution's guarantee of freedom of speech and expression. The Stolen Valor Act infringes upon speech protected by the First Amendment," Kennedy said.

The high court has in recent years rejected limits on speech. The justices struck down a federal ban on videos showing graphic violence against animals and rejected a state law intended to keep violent video games away from children. The court also turned aside the attempt by the father of a dead Marine to sue fundamentalist church members who staged a mocking protest at his son's funeral. In 1989, the court said the Constitution protects the burning of the American flag.

Justices Samuel Alito, Antonin Scalia and Clarence Thomas dissented in the Alvarez case.

"These lies have no value in and of themselves, and proscribing them does not chill any valuable speech," Alito said. "By holding that the First Amendment nevertheless shields these lies, the court breaks sharply from a long line of cases recognizing that the right to free speech does not protect false statements that inflict real harm and serve no legitimate interest."

Alvarez made his claims by way of introducing himself as an elected member of the Three Valleys Municipal Water District in Pomona, Calif. There is nothing to suggest that he received anything in exchange or that listeners especially believed him.

The government had defended the law as necessary to punish impostors to protect the integrity of military medals.

But Justices Stephen Breyer and Elena Kagan said in a separate opinion that there were ways for the government to stop liars "in less restrictive ways." One possibility would be to "insist upon a showing that the false statement caused a specific harm or at least was material, or focus its coverage on lies most likely to be harmful or on contexts where such lies are most likely to cause harm," Breyer said.

Civil liberties groups, writers, publishers and news media outlets, including The Associated Press, told the justices they worried that the law, and especially the administration's defense of it, could lead to more attempts by government to regulate speech.

Then-Gen. George Washington established military decorations in 1782, seven years before he was elected as the first president. Washington also prescribed severe military punishment for soldiers who purported to be medal winners but weren't.

It long has been a federal crime to wear unearned medals, but mere claims of being decorated were beyond the reach of law enforcement. The Stolen Valor Act aimed to solve that problem, and won significant support in Congress during a time of war.

Alvarez's lawyers challenged the law by acknowledging their client's lies, but also insisting that they harmed no one.

"Statutes suppressing or restricting speech must be judged by the sometimes inconvenient principles of the First Amendment," Kennedy said. "By this measure, the statutory provisions under which respondent was convicted must be held invalid, and his conviction must be set aside."