New Hampshire Gov. Chris Sununu (R) has signed a controversial measure that will limit the number of college students and military personnel who can vote in state elections.

The bill, signed on Friday and a source of partisan bickering in the statehouse for years, will require registered voters be permanent residents of New Hampshire, obtain a state driver's license within 60 days of voting and register their vehicles in New Hampshire.

The new law will take effect in 2019.

New Hampshire is the only U.S. state that does not require registered voters to be permanent residents in order to cast a ballot. The rule allows thousands of college and university students who study in the Granite State to cast votes in the precinct where they live, even if they remain residents of another state, so long as they do not also vote in their home states.

Republicans have been frustrated by the influx of student voters, who tend to back Democratic candidates, especially as the state has become one of the most closely fought battlegrounds in the country.

Hillary Clinton beat President Trump in New Hampshire by just 3,000 votes, or about 0.3 percentage points, in 2016. Sen. Maggie Hassan (D) defeated now-former Sen. Kelly Ayotte (R) by just 1,000 votes that same year.

Sununu, who in 2016 was seeking to replace Hassan in the governor's mansion, won in a relative landslide, beating his Democratic rival by 17,000 votes, or 2.3 percentage points.

Voters between the ages of 18 and 29 favored Democratic candidates in all three races, according to exit polls.

Though the measure won support from Republicans in the state legislature, Sununu had said he was skeptical that it was constitutional. He asked the state Supreme Court for an advisory opinion, and the court concluded, in a 3-2 vote, that the measure passed muster.

Sununu said the court's decision was sufficient to persuade him to sign the bill.

"House Bill 1264 restores equality and fairness to our elections, and the Supreme Court has ruled the bill is constitutional while affirming that New Hampshire has a compelling state interest in seeing this bill enacted," Sununu said as he signed the measure. "Finally, every person who votes in New Hampshire will be treated the same. This is the essence of an equal right to vote."

State Democrats and civil rights groups objected to the bill, which they said would make it harder for both students and members of the military to participate in elections.

"Gov. Sununu broke his word by signing this shameful attempt at partisan voter suppression into law, which is a giant step backward for our state and has the potential to disenfranchise thousands of Granite Staters," Hassan said in a statement. "Voting is the most fundamental right of our democracy, and I will continue working to ensure that all Granite Staters, including college students, can exercise their right to vote and fully participate in our democracy."

Sununu and other Republicans - including President Trump - have alleged in recent years that Democrats have bused hundreds or thousands of Massachusetts voters across state lines to register and vote on Election Day.

Secretary of State Bill Gardner, a Democrat elected to his post by the Republican-led legislature, has said that a few people have been prosecuted for voter fraud, but a months-long investigation by his office and the state Justice Department found no evidence of widespread fraud.

That investigation found that just four people out of about 743,000 votes cast appeared to have voted illegally. Of the 6,000 people who registered to vote on Election Day, only 66 did not have their identities confirmed. The investigation also found that while buses arriving at the polls may belong to companies in neighboring states, the voters on those buses were all New Hampshire residents.