Justice Samuel Alito delivered the opinion for a largely united court. He said the law could not be saved just because it evenhandedly prohibits disparagement of all groups.
"That is viewpoint discrimination in the sense relevant here: Giving offense is a viewpoint," Alito wrote.
He added that the disparagement clause in the law "offends a bedrock First Amendment principle: Speech may not be banned on the ground that it expresses ideas that offend."
All of the participating justices - Neil Gorsuch was not on the court when the case was argued - joined that part of Alito's opinion. Four justices peeled off from parts of the opinion where they say Alito opined on more than what was needed to decide the case.
The trademark office in 2011 said registering the trademark of the Slants, an Asian American rock group, would violate a part of the 1946 Lanham Trademark Act that prohibits registration of a trademark that "may disparage . . . persons, living or dead, institutions, beliefs, or national symbols, or bring them into contempt, or disrepute."
The office said the name was likely to disparage a significant number of Asian-Americans. But founder 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.
The outcome is likely to affect the legal case of the Washington Redskins, whose trademark registration was revoked in 2014 under the same disparagement clause.
The Redskins filed an amicus brief supporting the Slants, which was cited in the opinion. The Washington football team's case, however, is moving on a separate track.
"The team is thrilled with today's unanimous decision as it resolves the Redskins' long-standing dispute with the government," Redskins attorney Lisa Blatt said in a statement. "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."
Free speech advocates had supported The Slants, and the court's decision seemed likely from the oral arguments.
But some worried about what kinds of trademarks the government will 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. She added: "While this may be the right result under the First Amendment and the principles of free speech that are foundational to our country, it seems the responsibility will now pass to the public."
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, pending the Supreme Court's decision in the Slants case.
Registration of a trademark provides a nationwide defense against others who would try to use it.
The case is Matal v. Tam.