The Supreme Court on Thursday struck down a Minnesota law that bans all political apparel at polling places.

In a 7-2 ruling, the court said the state law violates the First Amendment's protection of free speech.

In delivering the opinion of the court, Chief Justice John Roberts said the law does not define what apparel is "political," a word he that said can be expansive.

"It can encompass anything 'of or relating to government, a government, or the conduct of governmental affairs,'" he said, quoting Webster's dictionary definition, "or anything 'of relating to, or dealing with the structure or affairs of government, politics, or the state,'" he added, quoting the American Heritage Dictionary.

"Under a literal reading of those definitions a button or T-shirt merely imploring others to 'Vote!' could qualify."

Roberts, however, said that Minnesota polling places are nonpublic forums that, under the court's precedent, can be subject to content-based restrictions, "so long as the regulation on speech is reasonable and not an effort to suppress expression merely because public officials oppose the speaker's view,'" he said, quoting court precedent.

He said states must be able to articulate some sensible basis for distinguishing what can be worn and what can't.

As Roberts noted, all 50 states and the District of Columbia have laws curbing various forms of speech in and around polling places on Election Day.

Justices Anthony Kennedy, Clarence Thomas, Ruth Bader Ginsburg, Samuel Alito, Elena Kagan and Neil Gorsuch joined Roberts in the majority.

Justice Sonia Sotomayor filed a dissenting opinion, which Justice Stephen Breyer joined.

Sotomayor said she would have sent the case to the Minnesota Supreme Court for a definitive interpretation of what constitutes political apparel.

"In holding that a polling place constitutes a nonpublic forum and that a state must establish only that its limitations on speech inside the polling place are reasonable, the court goes a long way in preserving states' discretion to determine what measures are appropriate to further important interests in maintaining order and decorum, preventing confusion and intimidation, and protecting the integrity of the voting process," she said.

"The Court errs, however, in declaring Minnesota's political apparel ban unconstitutional under that standard, without any guidance from the state's highest court on the proper interpretation of that state law."

At least nine other states - Delaware, Kansas, Montana, New Jersey, New York, South Carolina, Tennessee, Texas and Vermont - have similar laws, according the Minnesota Voters Alliance, which brought the case challenging Minnesota's ban.

Andrew Cilek, the founder and executive director of the group, which claims to be dedicated to ensuring election integrity, sued state election officials after he was twice turned away from the polls for wearing a "Don't Tread on Me" T-shirt. He was ultimately allowed to vote after an election judge took his information to refer him to the authorities.

The shirt included a picture of the Gadsden Flag and a small Tea Party logo. Cilek was also wearing a "Please I.D. Me" button with the website and phone number of Election Integrity Watch. Minnesota does not have a voter ID law.

State officials argued the century-old dress code law is needed to prevent voter intimidation and maintain the integrity of the election process.

Cilek was represented by the Pacific Legal Foundation, a conservative legal advocacy group, and supported by the America Civil Liberties Union, which argued in a friend of the court brief that Minnesota's ban was far broader than necessary to address the state's compelling interest in protecting the right to vote.

Updated at 11:32 a.m.