BOSTON (Reuters) - Massachusetts’ top court on Monday unanimously upheld a state requirement that people must register to vote 20 days before an election, ruling in a case that could impact the ability of thousands of citizens to cast ballots.

FILE PHOTO: A man walks up to the John Adams Courthouse, which houses the Massachusetts Supreme Judicial Court in Boston, Massachusetts, U.S., March 6, 2018. REUTERS/Nate Raymond/File Photo

The Massachusetts Supreme Judicial Court ruled in favor of the state’s top election official by reversing a lower court judge’s 2017 ruling that concluded the registration cut-off violated the state’s constitution.

The 7-0 ruling by the top court came in a lawsuit filed in 2016 by the American Civil Liberties Union of Massachusetts on behalf of two organizations, Chelsea Collaborative and MassVote, and several individual qualified voters.

The ACLU contended the 20-day restriction disenfranchises thousands of otherwise qualified voters. According to a brief filed by Massachusetts, 34 states have deadlines requiring voters to register seven to 30 days before elections.

Justice Kimberly Budd wrote that while a registration blackout period could be so far from election day that it would interfere with voters’ rights, the state had a rational basis to say it needed the 20 days to prepare for orderly elections.

“However, we acknowledge that, with the passage of time, voting regulations once considered constitutionally permissible may come to significantly interfere with the fundamental right to vote in light of conditions existing in contemporary society,” she wrote.

Budd said that by imposing a voter registration deadline, the state’s legislature has a continuing duty to ensure the cut-off period was no further from election day than needed to conduct an election.

Carol Rose, executive director of the ACLU of Massachusetts, said in a statement that the decision was a “blow, not just to Massachusetts voters, but to the democratic process.”

The decision reversed a July 2017 ruling by Suffolk County Superior Court Judge Douglas Wilkins that held that the 20-day cut-off violated the state’s constitution.

Secretary of the Commonwealth William Galvin, a Democrat who oversees the state’s elections, appealed that ruling, arguing the 20-day rule did not impose a severe burden on voting rights.

Galvin has proposed that the legislature pass a new law allowing election day registration. But lawyers for the state argued the issue of how to regulate registration should be left to the legislature to decide.

Galvin in a statement welcomed the ruling and urged the legislature to move swiftly to make same-day registration in Massachusetts a reality for voters in time for the 2020 presidential election.