LOS ANGELES — A federal appeals court on Friday rejected the Justice Department’s request for California to set aside disputed ballots received in the midterm election.

The 2-1 ruling by the 9th Circuit Court of Appeals panel is the latest setback for the Trump administration’s efforts to assert control over state-run elections.

The administration has alleged California sent ballots to some 20,000 people who may not be U.S. citizens. It wants the state to set those ballots aside and not count them until citizenship can be verified. California officials say the list is highly unreliable and most likely includes many people who are U.S. citizens.

A district court judge forcefully denied that request on Wednesday and warned that the Justice Department’s demands could disenfranchise citizens.

“As the district court found — and we discern no clear error — there is no feasible way to identify and segregate the ballots of specific individuals without potentially catastrophic effects on the entire system,” the appeals court wrote.

The ruling is the latest in an expansive legal battle between the federal government and the state before Election Day in the midterms Tuesday. Millions of people in California have already voted.

The majority opinion was authored by Judge Mark J. Bennett, who was appointed by President Donald Trump, and Judge Gabriel P. Sanchez, who was appointed by former President Joe Biden.

The Justice Department did not immediately respond to a request for comment on the ruling.

Hundreds of thousands of ballots have already been processed. Elections officials have said that processed votes are completely anonymized and can’t be matched back to the voters who submitted them.

The ruling comes during broader federal scrutiny of local elections, with the Trump administration issuing a raft of subpoenas in Alaska in a spoiler-candidate controversy. The Justice Department has also provided a list of alleged noncitizen voters to officials in Washington state.

Lawyers for the Justice Department have previously said they would appeal the 9th Circuit Court’s decision, which would take the case to the U.S. Supreme Court.

In his dissent, Judge Patrick J. Bumatay argued that California’s unwillingness to separate the ballots encourages the “violation of federal law.”

“California says it can do nothing to prevent illegal voting,” Bumatay, who was appointed by Trump, wrote. “That undermines the federal government’s interest in promoting election integrity and preventing the dilution of lawful votes.”

Bumatay also pushed back on the idea that California was incapable of setting aside the ballots for logistical or technical reasons as county officials have asserted.

It may be challenging, he conceded, “But difficulty is no reason for courts to throw our hands in the air and give up—not when the threat is illegal votes undermining our elections.”

Earlier on Friday, a federal judge in Washington ordered the Trump administration to share the disputed list of names with lawyers for the Coalition for Humane Immigrant Rights and the UCLA Voting Rights Project. They want the list so they can examine who is on the list and assess its impact on eligible voters.

It will be the first time that a nongovernment organization will have the opportunity to evaluate the merits of the list of some 20,000 names.

Prosecutors with the Trump administration have argued that there is just as much to lose from noncitizens illegally voting, arguing that to tally those votes would dilute the voice of citizens.