The Supreme Court on Thursday struck down Minnesota's broad ban on wearing "political apparel" at the polls, ruling the law violates the free speech rights of voters.

The 7-2 ruling said despite any "good intentions" by the state, regulation of such individual expression cannot be reasonably applied because of overly sweeping prohibitions.

A Minnesota voter had sued after being told to remove a "Please I.D. Me" button and Tea Party shirt at his polling place.

He argued such "passive, non-disruptive" expression should be allowed, while the state said the restrictions were a "reasonable, viewpoint-neutral" means to ensure polling integrity and reduce voter coercion.

"Minnesota, like other states, has sought to strike the balance in a way that affords the voter the opportunity to exercise his civic duty in a setting removed from the clamor and din of electioneering," Chief Justice John Roberts said. "While that choice is generally worthy of our respect, Minnesota has not supported its good intentions with a law capable of reasoned application."

All states have laws prohibiting direct campaigning, solicitation, or advocacy signs inside or near the polling station. The Supreme Court in 1992 upheld a Tennessee law prohibiting campaign materials within 100 feet of a polling place.

About 11 states and the District of Columbia go further, banning anyone wearing "political badges, political buttons, or other political insignia to be worn at or about the polling place" on election day.

Voting monitors and judges would ostensibly enforce the policy and settle any disputes.

Andrew Cilek, a local political activist in Minneapolis who brought the suit, was told twice in 2010 to remove his Tea Party-related apparel. When he returned a third time with his lawyer, Cilek was given a ballot but his name was recorded for possible prosecution, which can include a $300 fine.

In dissent, Justice Sonia Sotomayor said the high court acted too hastily in tossing out Minnesota’s statute, and should have first given state courts a chance to offer a "definitive interpretation" of the law.

"Especially where there are undisputedly many constitutional applications of a state law that further weighty state interests," she said, "the Court should be wary of invalidating a law without giving the state's highest court an opportunity to pass upon it."

She was supported by Justice Stephen Breyer.

During the February oral arguments, the justices mentioned a range of possible political apparel that could be regulated, including that related to the #MeToo movement; rainbow-colored shirts supporting gay rights; union apparel; and pro-Trump "Make America Great Again" gear.

The balancing test for the high court was a tricky one. Roberts in his opinion noted any limitations on speech content would have to have a "compelling government interest." But "reasonable" restrictions on speech on government property might be allowed if they were viewpoint-neutral. But here, he said Minnesota stepped too far over the free-speech line.

The case is Minnesota Voters Alliance v. Mansky (16-1435).