WASHINGTON — The Supreme Court on Monday struck down part of a law that bans offensive trademarks, ruling in favor of an Asian-American rock band called the Slants and giving a major boost to Washington’s NFL team in its separate legal fight over the team name.

The justices were unanimous in saying that the 71-year-old trademark law barring disparaging terms infringes on free speech rights.

“It offends a bedrock First Amendment principle: Speech may not be banned on the ground that it expresses ideas that offend,” Justice Samuel Alito said in his opinion for the court.

Slants founder Simon Tam tried to trademark the band name in 2011, but the U.S. Patent and Trademark Office denied the request on the grounds that it disparages Asians. A federal appeals court in Washington later said the law barring offensive trademarks is unconstitutional.

Washington’s NFL team made similar arguments after the trademark office ruled in 2014 that the team’s nickname offends American Indians and canceled the team’s trademark. A federal appeals court in Richmond put the team’s case on hold while waiting for the Supreme Court to rule in the Slants case.

Tam insisted he was not trying to be offensive, but wanted to transform a derisive term into a statement of pride. Washington’s NFL team also contends its name honors American Indians, but the team has faced decades of legal challenges from Indian groups that say the name is racist.

Despite intense public pressure to change the name, team owner Dan Snyder has refused, saying in the past that it “represents honor, respect and pride” for Native Americans. Snyder issued a quick response to the decision on Monday: “I am THRILLED. Hail to the Redskins.”

Team attorney Lisa Blatt said the court’s decision effectively resolves the team’s longstanding dispute with the government.

“The Supreme Court vindicated the team’s position that the First Amendment blocks the government from denying or canceling a trademark registration based on the government’s opinion,” Blatt said.

Trademark office spokesman Paul Fucito said officials are reviewing the court’s ruling and plan to issue further guidance on how they will review trademark applications going forward.

While the justices all agreed on the outcome, they split in their rationale for the decision. Alito rejected arguments that the government has an interest in preventing speech that is offensive to certain groups.

“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 said in a part of his opinion joined by Chief Justice John Roberts and Justices Clarence Thomas and Stephen Breyer.

Writing separately, Justice Anthony Kennedy said a ban on disparaging trademarks was a clear form of viewpoint discrimination that is forbidden under the First Amendment.

“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 said in an opinion joined by Justices Ruth Bader Ginsburg, Sonya Sotomayor and Elena Kagan.