The Supreme Court on Monday night rejected a pandemic-related request from Democrats and civil rights groups to extend the deadline for counting mail-in ballots received after Election Day in the key battleground state of Wisconsin.

The vote was 5 to 3, with the Republican-nominated conservatives in the majority and the Democratic-nominated liberals in dissent. The court’s order showed the deep division within the court about the series of pandemic-related election cases that have come to dominate its agenda.

The court’s conservatives say they must defer to state officials on election decisions made in the largely Republican-run states, and the liberal justices say there is a need for dramatic action by judges to ensure the franchise for endangered voters during an unprecedented time.

“On the scales of both constitutional justice and electoral accuracy, protecting the right to vote in a health crisis outweighs conforming to a deadline created in safer days,” liberal Justice Elena Kagan wrote in dissent.

Conservative Justice Brett M. Kavanaugh answered that Kagan’s “green light to federal courts to rewrite dozens of state election laws around the country over the next two weeks seems to be rooted in a belief that federal judges know better than state legislators about how to run elections during a pandemic.”

The decision was a victory for Republicans and President Trump in a state where he narrowly won in 2016 and polls show him behind this year. While Democrats have embraced mail-in voting, Trump has railed against it.

“The most powerful rebuke to Republican judicial activism is to defeat Trump and elect Joe Biden and Kamala Harris in a landslide,” Wisconsin Democratic Party Chairman Ben Wikler said in a statement after the Supreme Court’s ruling was announced. “The Democratic Party of Wisconsin will double down on making sure that every Wisconsin voter knows how to exercise their right to vote in the final eight days of this election.”

Wisconsin Republican Party Chairman Andrew Hitt said: “Democrats’ attempts to get the courts to rewrite Wisconsin’s election laws on the eve of an election have failed.”

The court in coming days will consider a similar issue in other battleground states. Republicans in North Carolina are challenging an extension for ballots postmarked before and on Election Day but received afterward. And the Pennsylvania GOP has again asked the court to overturn an extension granted there by the state Supreme Court.

The court last week allowed that decision to stand on a 4-to-4 vote, with Chief Justice John G. Roberts Jr. siding with the liberals. But new Justice Amy Coney Barrett begins work Tuesday and is set to shift the court’s balance yet again.

In Wisconsin, a district judge had ruled with the plaintiffs, and extended by six days the deadline to receive ballots postmarked by Election Day. He accepted the argument that the coronavirus pandemic and the accompanying surge in mail voting demand changes to accommodate voters and ensure ballots are counted.

But the Republican National Committee, the Wisconsin Republican Party and the state’s majority-GOP legislature intervened to defend the existing deadline, and earlier this month a divided panel of the U.S. Court of Appeals for the 7th Circuit reinstated the requirement that mail ballots be returned by 8 p.m. on Election Day.

Judges Frank H. Easterbrook and Amy J. St. Eve — appointees of President Ronald Reagan and Trump, respectively — wrote that decisions about how to cope with the effects of the pandemic are “principally a task for the elected branches of government.”

Judge Ilana Diamond Rovner issued a sharp dissent, calling the situation facing Wisconsin voters “a travesty.”

“We cannot turn a blind eye to the present circumstances and treat this as an ordinary election,” wrote Rovner, an appointee of President George H.W. Bush. “Today, in the midst of a pandemic and significantly slowed mail delivery, this court leaves voters to their own devices. Good luck and G-d bless, Wisconsin. You are going to need it.”

The civil rights groups and Democrats say they were seeking only similar accommodations to those the Supreme Court approved in April during the state’s primary. Faced with a crush of requests for mail-in ballots the week before the primary, the court agreed that ballots postmarked by the primary date but received days afterward should be counted.

That action “resulted in approximately 80,000 ballots being counted that would have otherwise been rejected as untimely,” said a brief for the groups, which included Black Leaders Organizing for Communities.

The Supreme Court has been refereeing similar fights in emergency requests and rarely explaining its decision-making. But the order in the Wisconsin case was different, with four justices writing.

Roberts was the justice in the middle. He wrote that, in general, he opposed federal judges intervening in the “thick of election season to enjoin enforcement of a State’s laws.” But the Pennsylvania case involved the authority of state courts to interpret their own constitutions, he wrote.

“Different bodies of law and different precedents govern these two situations and require, in these particular circumstances, that we allow the modification of election rules in Pennsylvania but not Wisconsin,” he wrote.

Kavanaugh and Justice Neil M. Gorsuch opposed the extensions in both cases. Both said that it is up to state legislatures to make decisions, not courts.

“It’s indisputable that Wisconsin has made considerable efforts to accommodate early voting and respond to COVID,” Gorsuch wrote, referring to the disease caused by the novel coronavirus. “The district court’s only possible complaint is that the state hasn’t done enough. But how much is enough? . . . The Constitution provides that state legislatures — not federal judges, not state judges, not state governors, not other state officials — bear primary responsibility for setting election rules.”

Kavanaugh agreed with Wisconsin officials that they had already done plenty to make voting easier during the pandemic, with early voting and fewer restrictions on absentee voting.

“The Wisconsin Elections Commission has mailed 1,706,771 absentee ballots to Wisconsin voters. And it has already received back from voters 1,344,535 completed absentee ballots,” he wrote. “As those statistics suggest, the dissent’s charge that Wisconsin has disenfranchised absentee voters is not tenable.”

He added: “Wisconsin’s deadline is the same as that in 30 other States and is a reasonable deadline given all the circumstances.”

The other justices in the majority, Clarence Thomas and Samuel A. Alito Jr., did not state the reasons for their votes.

Kagan, joined by Justices Stephen G. Breyer and Sonia Sotomayor, said it was unreasonable for the court not to approve the same extension it granted during Wisconsin’s April primary.

“Because of the court’s ruling, state officials counted 80,000 ballots — about five percent of the total cast — that were postmarked by Election Day but would have been discarded for arriving a few days later,” she wrote. “Today, millions of Wisconsin citizens are preparing to vote in the November election. But COVID is not over. In Wisconsin, the pandemic is much worse — more than 20 times worse, by one measure — than it was in the spring.”

She wrote that the state legislature has “not for a moment” considered whether new accommodations are needed to ensure voters can cast ballots safely and that the majority did not dispute the lower court’s finding that as many as 100,000 ballots might arrive too late to be counted.

Kagan wrote that the court’s usual reason for not agreeing to election changes is that it could confuse voters. But she said that could not be the case here.

“To the contrary, it would prevent the state from throwing away the votes of people actively participating in the democratic process,” she wrote. “And what will undermine the ‘integrity’ of that process is not the counting but instead the discarding of timely cast ballots that, because of pandemic conditions, arrive a bit after Election Day.”

Elise Viebeck and Rosalind S. Helderman contributed to this report.