The Supreme Court. (Jonathan Newton/The Washington Post)

The federal government has violated the First Amendment by refusing to register trademarks that officials consider disparaging, the Supreme Court ruled unanimously Monday in a decision that provides a boost to the Washington Redskins’ efforts to hang on to the team’s controversial name.

The ruling came in a case that involved an Asian American rock group called the Slants, which tried to register the band’s name in 2011. The band was turned down by the U.S. Patent and Trademark Office because of a law against registering trademarks that are likely to disparage people or groups.

In a ruling against the government, the court said the “disparagement clause” of the federal trademark law was not constitutional, even though it was written evenhandedly, prohibiting trademarks that insult any group.

“This provision violates the Free Speech Clause of the First Amendment,” Justice Samuel A. Alito Jr. wrote in a section of the opinion supported by all participating justices. “It offends a bedrock First Amendment principle: Speech may not be banned on the ground that it expresses ideas that offend.”

The ruling — and a second one Monday that struck down a North Carolina law restricting registered sex offenders from social-media sites — bolsters the reputation of the Supreme Court as protector of First Amendment rights.

“At a time when some have claimed that speech may and should be regulated or censored if it is offensive, hurtful, or dangerous, the justices’ firm insistence that governments may not silence messages they dislike is noteworthy and important,” Notre Dame law professor Richard W. Garnett said in a statement.

Redskins owner Daniel Snyder was more succinct in a statement: “I am THRILLED. Hail to the Redskins.” The team was not involved in the case at hand, although the court several times mentioned an amicus brief filed by the Redskins.

The case centered on the 1946 Lanham Act, which in part prohibits registration of a trademark that “may disparage . . . persons, living or dead, institutions, beliefs, or national symbols, or bring them into contempt, or disrepute.”

But the founder of the Slants, Simon Tam, said the point of the band’s name is just the opposite — an attempt to reclaim a slur and use it as “a badge of pride.”

In a Facebook post after the decision, Tam wrote: “After an excruciating legal battle that has spanned nearly eight years, we’re beyond humbled and thrilled to have won this case at the Supreme Court. This journey has always been much bigger than our band: it’s been about the rights of all marginalized communities to determine what’s best for ourselves.”

Tam lost in the first legal rounds. But then a majority of the U.S. Court of Appeals for the Federal Circuit said the law violates the First Amendment’s guarantee of free speech. The government may not “penalize private speech merely because it disapproves of the message it conveys,” a majority of that court found.

(Jorge Ribas/The Washington Post)

Free-speech advocates had supported the Slants, and the court’s decision seemed likely from the oral arguments.

But some ethnic and minority groups worried about what kinds of trademarks the government would now be forced to register. “It seems this decision will indeed open the floodgates to applications for all sorts of potentially offensive and hateful marks,” said Lisa Simpson, an intellectual-property lawyer in New York.

While unified on the bottom line, the two groups of justices wrote separate opinions in support of the ruling.

“Speech that demeans on the basis of race, ethnicity, gender, religion, age, disability, or any other similar ground is hateful; but the proudest boast of our free speech jurisprudence is that we protect the freedom to express the thought we hate,” Alito wrote in part of the opinion, joined by Chief Justice John G. Roberts Jr. and Justices Clarence Thomas and Stephen G. Breyer.

Justice Anthony M. Kennedy wrote a concurring opinion that was joined by Justices Ruth Bader Ginsburg, Sonia Sotomayor and Elena Kagan.

“A law that can be directed against speech found offensive to some portion of the public can be turned against minority and dissenting views to the detriment of all,” Kennedy wrote.

The Slants were not happy to be associated with the Redskins — band members oppose the team mascot — but the band and the team have argued that the law was unevenly applied and gave too much control to the government.

“The Supreme Court vindicated the team’s position that the First Amendment blocks the government from denying or cancelling a trademark registration based on the government’s opinion,” Lisa Blatt, a lawyer representing the Redskins, said in a statement.

The team’s trademark registration was canceled in 2014 after decades of use. The team asked a district judge in Virginia to overturn the cancellation and was refused. The case is now in the U.S. Court of Appeals for the 4th Circuit in Richmond, awaiting the Slants decision.

The Native Americans challenging the team were disappointed, said their attorney Jesse Witten.

“Nothing in the opinion undermines the decision of the [Patent and Trademark Office appeal board] or the District Court that the term ‘redskin’ disparages Native Americans,” Witten’s statement read.

Justice Neil M. Gorsuch did not take part in Matal v. Tam.

The court showed no hesi­ta­tion in striking down the North Carolina law, which was meant to keep registered sex offenders off social networks and websites that could bring them into contact with potential targets.

Kennedy said the law was far too broad, enacting “a prohibition unprecedented in the scope of First Amendment speech it burdens.”

By prohibiting sex offenders from using those websites, “with one broad stroke North Carolina bars access to what for many are the principal sources for knowing current events, checking ads for employment, speaking and listening in the modern public square, and otherwise exploring the vast realms of human thought and knowledge,” Kennedy wrote.

Lester Gerard Packingham is one of about 1,000 people prosecuted under the law. As a 21-year-old in 2002, he had sex with a 13-year-old girl and pleaded guilty to taking indecent liberties with a child. As a registered sex offender, he was prohibited from gaining access to commercial social-networking sites.

But in 2010, he celebrated the dismissal of a traffic ticket on his Facebook profile:

“No fine, no court cost, no nothing spent. . . . Praise be to GOD, WOW! Thanks JESUS.”

One North Carolina court struck down the law and his conviction, but the state Supreme Court reversed, saying the law was “carefully tailored” to meet the state’s goals.

None of the justices agreed with that. “A fundamental principle of the First Amendment is that all persons have access to places where they can speak and listen, and then, after reflection, speak and listen once more,” Kennedy wrote. He was joined fully in his opinion by the court’s liberals: Ginsburg, Breyer, Sotomayor and Kagan.

Gorsuch did not take part in the case.

The rest of the court agreed North Carolina’s law could not stand. But Alito said Kennedy had gone too far in his “musings” and risked sending the message that “states are largely powerless to restrict even the most dangerous sexual predators from visiting any internet sites.”

He was joined by Roberts and Thomas in that concurring opinion.

The case is Packingham v. North Carolina.

Ian Shapira contributed to this report.