A New York federal judge is upholding New York's ban on voters photographing their marked ballots in polling places. The judge says the First Amendment is trumped by the law's stated goal to cut down on election fraud via vote buying and extortion.

US District Judge P. Kevin Castel said the statute deprives a perpetrator of election fraud the modern-day means to verify that a target voted a certain way. That verification method is a selfie of a voter holding a marked ballot at a polling place, which would then be posted to social media, he said.

"The State's interest in the integrity of its elections is paramount. The law is also narrowly tailored," Castel wrote (PDF) Thursday. "Alternatively, the Court finds that the statute is a reasonable, viewpoint-neutral restriction of speech within a non-public forum."

Castel's ruling contradicts decisions by judges in Indiana, Michigan, and New Hampshire. Courts in those states have ruled against bans on voting-booth selfies.

The New York judge said that any restriction on speech is only minimal, too.

"Voters can still post to social media (using messages that contain both words and images), attend rallies, donate to campaigns, volunteer, or express their views in a multitude of ways without taking photographs at polling sites," the judge wrote.

The New York law was first enacted in 1890 and says that violators are guilty of a misdemeanor, which carries a maximum year in prison, if they show their "ballot, after it is prepared for voting, to any person so as to reveal the contents."

The judge also set aside a challenge by voters to New York City's law barring the public, but not the accredited press, from photographing polling sites.

"The City Board's policy prohibiting photography is not a content-based restriction and is not in tension with the First Amendment," he ruled. "This policy is narrowly tailored to address significant state interests, such as avoiding longer wait times at the polls."

As many as 17 states bar ballot-booth selfies.

A lawyer for the voters who challenged the polling rules said the decision would be appealed.