The Supreme Court on Thursday struck down a federal law that made it a crime to falsely claim being awarded a top military honor, saying the law smacked of an Orwellian Truth Ministry and threatened free speech.

The court invalidated the Stolen Valor Act, under which a California man, Xavier Alvarez, 54, was convicted for claiming falsely in 2007 that he had been awarded the Medal of Honor, the nation’s highest award for valor.

But Alvarez’s attorneys convinced a lower court that his untruths were protected by the First Amendment’s guarantee of free speech. And Thursday, the Supreme Court agreed in a 6 to 3 decision.

“Lying was his habit,” Justice Anthony M. Kennedy wrote of Alvarez. He “lied when he said that he played hockey for the Detroit Red Wings and that he once married a starlet from Mexico.”

And he lied “in announcing he held the . . . Medal of Honor,” Kennedy wrote. “None of this was true. For all the record shows . . . [the] statements were but a pathetic attempt to gain respect that eluded him.”

But they are not illegal, he concluded.

“Fundamental constitutional principles require that laws enacted to honor the brave must be consistent with the precepts of the Constitution for which they fought,” Kennedy wrote in an 18-page opinion that was joined by Chief Justice John G. Roberts Jr. and justices Ruth Bader Ginsburg and Sonia Sotomayor.

Justice Stephen G. Breyer wrote a concurring opinion, in which Justice Elena Kagan joined.

But in a dissenting opinion, Justice Samuel A. Alito Jr. wrote: “Only the bravest of the brave are awarded the . . . Medal of Honor, but the Court today holds that every American has a constitutional right to claim to have received this singular award.”

He was joined by Justices Antonin Scalia and Clarence Thomas.

Veterans groups also were dismayed.

“Public humiliation is now the most effective tool to expose the delusional Walter Mittys of American Society,” Jan C. Scruggs, founder of the Vietnam Veterans Memorial Fund, which built the Vietnam Wall, said in an e-mail, “Military recruiters are happy to welcome those desiring to be valorous in combat into the Armed Forces.”

The Veterans of Foreign Wars of the United States “is greatly disappointed,” the organization’s commander in chief, Richard L. Denoyer, said in a statement. “Despite the ruling, the VFW will continue to challenge far-fetched stories, and to publicize these false heroes to the broadest extent possible as a deterrent to others.”

Harold A. Fritz, president of the South Carolina-based Congressional Medal of Honor Society and a recipient of the medal during the Vietnam War, said: “It’s more than just a piece of metal suspended on a piece of cloth on a pin. . . . And people who abuse that . . . need to be penalized.”

“I’m certainly not saying we should be the policeman for every lie that takes place,” he said.

But this was Kennedy’s concern.

He worried that the law, if upheld, would let the government start “a list of subjects about which false statements are punishable.”

“Our constitutional tradition stands against the idea that we need Oceania’s Ministry of Truth,” he wrote, referring to the agency of propaganda in George Orwell’s 1949 novel “Nineteen Eighty-Four.”

Jonathan D. Libby, the Los Angeles-based federal public defender who argued the case before the court on behalf of Alvarez, said in a telephone interview: “We’ve never said that people shouldn’t be upset about these things. Lying is wrong, and lying about military honors is wrong. Mr. Alvarez has admitted as such. But what the court said today was it’s not illegal.”

“The First Amendment protects a lot of what we as Americans get to say,” he said. “The government doesn’t get to decide what we can and cannot say.”

The case generated huge interest and divided First Amendment advocates, including the news media, and veterans groups, who saw the act as a necessary weapon to discourage what appears to be a boomlet of self-aggrandizers.

According to a brief filed by the VFWars and two dozen veterans groups, “Pretenders have included a U.S. Attorney, member of Congress, ambassador, judge, Pulitzer Prize-winning historian and bestselling author, manager of a Major League Baseball team, Navy captain, police chief, top executive at a world-famous research laboratory, director of state veterans programs, university administrator, pastor, candidate for countywide office, mayor, physician, and more than one police officer.”

Fritz, of the Medal of Honor society, said many of the “charlatans” have used bogus medals and award citations to bolster their claims, and thus are seldom second-guessed.

“There needs to be a penalty for this type of ruse,” he said. “And we’re not stopping. We’ll continue to look at other ways of attacking this so that we might be able to get some more teeth in the dragon’s mouth.”

The Supreme Court in recent years has been protective of speech rights in several high-profile cases. The court struck down a broadly written law on depicting animal cruelty, upheld the rights of a controversial group that demonstrates at military funerals and blocked a California law that attempted to outlaw the sale of violent video games to minors.

The Reporters Committee for Freedom of the Press and 23 news organizations, including The Washington Post, filed a brief supporting Alvarez, arguing that upholding the law would reverse “the basic presumption against official oversight of expression.”

Veterans groups, on the other hand, said falsely claiming the honors was theft.

Christian Davenport contributed to this report.