The U.S. Supreme Court. (Ricky Carioti/The Washington Post)

The Supreme Court on Thursday struck down Minnesota’s ban on wearing “political” apparel to polling places, saying that the state’s intentions may be good but that its law was too broad and open to differing interpretations.

The 7-to-2 decision, written by Chief Justice John G. Roberts Jr., was careful not to cast constitutional doubt on restrictions every state imposes to protect the solemnity of the voting booth.

But Minnesota’s prohibition on the wearing of a “political badge, political button or other political insignia” raised more questions than it answered, Roberts wrote, and gave too much discretion to volunteer election judges trying to figure out what counted as “political” and what did not.

“The state must be able to articulate some sensible basis for distinguishing what may come in from what must stay out,” Roberts wrote. “Here, the unmoored use of the term ‘political’ in the Minnesota law, combined with haphazard interpretations the state has provided in official guidance and representations to this court, cause Minnesota’s restriction to fail even this forgiving test.”

The Supreme Court decided 25 years ago that states could ban electioneering and distributing campaign materials within 100 feet of polling places, and all states have restrictions.

But Minnesota and nine other states go further. Minnesota’s clothing and button ban has been interpreted to include the names of political parties, candidates, support for or opposition to a ballot question; materials designed to influence voting; and the promotion of groups with recognizable political views, such as unions and the U.S. Chamber of Commerce.

On Election Day 2010, Andrew Cilek, executive director of the Minnesota Voters Alliance, was stopped at the polls for wearing a tea party T-shirt and a button saying, “Please I.D. Me.” (The button issue has dropped out of the case.)

Cilek was told that he could not vote without covering up or losing the T-shirt. Eventually, he was allowed to vote.

At the oral argument, the justices peppered Minnesota’s lawyers with hypotheticals about what would and would not be allowed, and Roberts replayed the “riddles” he said state lawyers struggled to answer:

“A shirt declaring ‘All Lives Matter,’ we are told, could be ‘perceived’ as political. How about a shirt bearing the name of the National Rifle Association? Definitely out. That said, a shirt displaying a rainbow flag could be worn ‘unless there was an issue on the ballot’ that ‘related somehow . . . to gay rights.’ A shirt simply displaying the text of the Second Amendment? Prohibited. But a shirt with the text of the First Amendment? ‘It would be allowed.’ ”

The court majority seemed to approve of laws in California and Texas, provided as examples of how states may regulate in the area. California’s law bans displays of a “candidate’s name, likeness or logo,” for example.

But the court was reluctant to answer every question “or pass on the constitutionality of laws that are not before us.”

Justices Sonia Sotomayor and Stephen G. Breyer dissented, partly because of the route the case took. The challengers went to federal court with their complaint, alleging it violated their free speech rights.

Sotomayor wrote that the Supreme Court should have first given the Minnesota Supreme Court a chance to interpret the law. That might have provided clearer guidance for election judges on what the law covered.

All justices agreed that states may impose restrictions on speech at polling places.

“Casting a vote is a weighty civic act, akin to a jury’s return of a verdict, or a representative’s vote on a piece of legislation,” Roberts wrote. “It is a time for choosing, not campaigning. The state may reasonably decide that the interior of the polling place should reflect that distinction.”

The case is Minnesota Voters Alliance v. Mansky.