CONCORD, N.H. (AP) — 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. It was struck down a year ago, but the state appealed to the 1st U.S. Circuit Court of Appeals in Boston, which heard arguments earlier this month.

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

The American Civil Liberties Union-New Hampshire brought the case on behalf of voters who were investigated after posting ballot photos.