Conservatives on the Supreme Court on Monday upheld Ohio’s strict method of removing infrequent voters from the rolls, a process that challengers of the law say disproportionately affects poor and minority voters.

Justice Samuel A. Alito Jr., writing for the majority in the 5-to-4 decision, said Ohio’s disputed process of purging voters who may have moved met the requirements of the National Voter Registration Act (NVRA).

The decision came under immediate criticism, beyond the dissenters on the court. Liberal groups and minority advocates said it gave states a green light to impose procedures that studies have shown tend to impact urban areas.

The subtext of the decision was a continuing battle between Republicans and Democrats over laws that regulate who gets to vote and when, including voter-ID requirements and restrictions on early voting. Republicans say the integrity of the process demands ensuring that only the eligible vote, while Democrats say that voter fraud is practically nonexistent and that the goal should be to enfranchise all who are eligible.

It is no surprise the case comes from Ohio, which has the nation’s strictest law on removing voters and is a closely divided state almost always seen as a battleground in national politics.

In the past, the Justice Department has opposed Ohio’s process as inconsistent with federal law. But the department switched its position after President Trump was elected. The president tweeted about the ruling from Singapore: “Just won big Supreme Court decision on Voting! Great news!”

Unlike many voting cases that come before the court, Monday’s case centered not on grand constitutional principles but on interpreting seemingly contradictory directives of federal law.

Federal law prohibits removing voters simply because they failed to vote. But it also calls on states to keep accurate rolls and allows them to come up with their own systems for removing voters believed to have moved or died.

Ohio sends a notice after a voter skips a single federal election cycle. If the voter fails to respond and does not vote in the next two elections, that person is presumed to have moved and removed from the rolls.

“We have no authority to second-guess Congress or to decide whether Ohio’s [law] is the ideal method for keeping its voting rolls up to date,” Alito wrote. “The only question before us is whether it violates federal law. It does not.”

The court’s dissenters said Ohio violates a prohibition in federal law against removing voters simply because they are exercising their right not to vote. And Justice Sonia Sotomayor, writing only for herself, warned that those who support voting rights should be vigilant in the wake of the court’s decision.

“Communities that are disproportionately affected by unnecessarily harsh registration laws should not tolerate efforts to marginalize their influence in the political process, nor should allies who recognize blatant unfairness stand idly by,” Sotomayor wrote.

Alito responded: “Justice Sotomayor’s dissent says nothing about what is relevant in this case — namely, the language of the NVRA,” adding that she “has not pointed to any evidence in the record that Ohio instituted or has carried out its program with discriminatory intent.”

One of the plaintiffs in the case was Larry Harmon, whose experience was indicative of others who were surprised to find themselves removed from voter rolls, lawyers said.

After voting in the 2008 presidential election, Harmon opted not to vote in 2009 or 2010. Ohio sent him a notice, but Harmon said he does not remember receiving it. According to briefs in the case, Harmon “expressed his dissatisfaction with the candidates by exercising his right not to vote.” When he showed up to vote in 2015, he was told he was no longer allowed, even though he had not changed his residence or otherwise become ineligible.

A panel of the U.S. Court of Appeals for the 6th Circuit ruled for challengers, and more than 7,500 voters who otherwise would have been declared ineligible were allowed to vote in the 2016 election.

But the Supreme Court majority said the appeals court was wrong because Ohio’s process does not conflict with federal directives.

“It does not strike any registrant solely by reason of the failure to vote,” Alito wrote. “Instead, as expressly permitted by federal law, it removes registrants only when they have failed to vote and have failed to respond to a change-of-residence notice.”

Alito was joined by Chief Justice John G. Roberts Jr. and Justices Anthony M. Kennedy, Clarence Thomas and Neil M. Gorsuch.

Justice Stephen G. Breyer dissented, joined by Justices Sotomayor, Ruth Bader Ginsburg and Elena Kagan.

Breyer said the federal law’s protections of infrequent voters “are most naturally read to prohibit a State from considering a registrant’s failure to vote as part of any process” that results in a purge.

He said that because voters are unlikely to return a card from the government asking them to re-up their voting status — it is just as likely to be mistaken for junk mail, he said — Ohio’s reliance on unreturned cards is misplaced.

He noted that about 1 million people did not return cards sent from the state, representing about 13 percent of Ohio’s voting population. Studies, he said, showed that only about 4 percent of Americans moved outside their counties.

“The streets of Ohio’s cities are not filled with moving vans,” he said.

Sotomayor in her dissent said that whether Ohio intended to discriminate or not, friend-of-the-court briefs in the case showed that “low voter turnout rates, language-access problems, mail delivery issues, inflexible work schedules, and transportation issues, among other obstacles, make it more difficult for many minority, low-income, disabled, homeless, and veteran voters to cast a ballot or return a notice.”

She noted a study that showed African-American-majority neighborhoods in downtown Cincinnati had 10 percent of their voters removed since 2012, “as ‘compared to only 4% of voters in a suburban, majority-white neighborhood.’ ”

Ohio Attorney General Mike DeWine (R) praised the court’s decision.

“I am pleased that the United States Supreme Court agreed that Ohio was following federal law in maintaining accurate voter rolls,” he said in a statement. “I congratulate our attorneys throughout this case for their exceptional work in documenting how this process, used by Democrat and Republican secretaries of state, is indeed lawful.”

Liberal groups described the ruling as dire.

“Our worry is that other states will take this decision as a green light to implement more aggressive voter purges as the 2018 elections loom,” Myrna Pérez, director of the Voting Rights and Elections Project at the Brennan Center for Justice, said in a statement.