A federal appeals court in Boston says a New Hampshire law that prohibited voters from posting photos of their ballots online is unconstitutional.

Under a law that took effect two years ago, posting a photo of a completed ballot is a violation punishable by a fine of up to $1,000. The law was struck down a year ago, but the state appealed to the 1st U.S. Circuit Court of Appeals, which heard arguments this month.

Lawyers for the state contended the ban would prevent voter coercion. But the appeals court said in its ruling Wednesday that doesn't justify imposing restrictions on free speech.

The American Civil Liberties Union-New Hampshire brought the case on behalf of people who were investigated after posting ballot photos showing how they voted.