Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A New Hampshire judge dismissed a state law that opponents said made it more complicated for students to register to vote, calling it "unconstitutional," "discriminatory" and "unreasonable."

New Hampshire remains a general election swing state, and after having lost by less than 3,000 votes in 2016, President Donald Trump has hoped to flip the state in his favor this year. Historically, college students have voted in larger numbers for Democrats.

In a 54-page ruling made public Thursday, Superior Court Judge David A. Anderson said the law, known as Senate Bill 3, was "unconstitutional for unreasonably burdening the right to vote and violating equal protection under the New Hampshire Constitution."

The state Democratic Party, the League of Women Voters and numerous college students sued in 2017 to block the Republican-backed law, which required new voters to fill out complicated forms and expose themselves to possible criminal prosecution and civil fines if they didn't turn over certain proof-of-residence documents.

Experts testified at trial about how complicated the forms were, noting that the first option given for voters was a sentence more than 100 words long.

The "readability scores alone indicated that the forms would be very difficult for the average adult to read and understand," one of the experts testified.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The judge agreed that "the language contained on the forms is needlessly complex, both in length and diction."

"Based on the expert testimony, the court finds there exists strong evidence that SB 3, if fully implemented, will suppress voter turnout," Anderson added.

The state contended that the law was necessary to combat voter fraud.

The judge noted that there has been an average of one confirmed case of voter fraud a year in New Hampshire over the past 20 years, and he concluded that the requirements in the law did little to address fraud and only made registering more difficult.

The law falls "disproportionately on groups of individuals who use same-day registration more frequently than others," he wrote. "Young, mobile, low-income and homeless voters will all encounter SB 3 and be exposed to its penalties at a higher rate than other voters. Therefore the burdens imposed by the law are discriminatory, in addition to being unreasonable."

Lawyer William Christie, who represented the state Democratic Party, said the party was "gratified" by the ruling.

"The opinion sends a loud and clear message that voter suppression efforts will not be tolerated," Christie said.

State Solicitor General Daniel Will said in a statement, "After an initial review of the order, we expect to appeal the decision to the New Hampshire Supreme Court."

Download the NBC News app for breaking news and politics

Senate Bill 3 was one of two bills aimed at tightening access to the ballot box that the state's Republican-controlled Legislature passed in the wake of the 2016 election, in which Trump lost the state and Republican Sen. Kelly Ayotte lost her seat by an even smaller margin.

The other law, known as House Bill 1264, requires students and other transient people to pay state motor vehicle licensing and registration fees if they vote and drive there, creating financial hurdles in a state where car registration can cost hundreds of dollars.

A legal battle to block that law is ongoing.