A federal judge has turned down an emergency request from the Department of Justice that would have forced California election officials to set aside thousands of ballots in the midterm elections. The request was described as unprecedented.

The department wanted the state to stop processing ballots linked to 20,000 people whom federal officials describe as "likely" noncitizens. In a 26-page ruling issued Wednesday evening, U.S. District Judge David Carter, a Clinton appointee, denied the department's motion for a temporary restraining order.

"Never before in American history has the federal government, on the eve of an election, sought to coerce a state and local government to abandon their own Constitutional elections procedures and bend to the will of the Executive Branch," Carter wrote. He also voiced concern that the step could disenfranchise eligible voters and create chaos.

Closing his order, the judge wrote: "Once a vote is segregated, lasting harm has occurred." He added that if the Executive can discount votes and threaten an ongoing election over unproven allegations, "then our democracy is in danger. This Court declines to be a party to such process." Carter said the government can instead keep pursuing indictments against people who vote illegally as noncitizens. Justice Department officials say they have charged dozens of people over the past two months with registering or voting without U.S. citizenship.

California state and local officials had argued that the department's list is unreliable. A preliminary analysis by Los Angeles County found that many people on it do not have active voter registrations. Officials also said that setting ballots aside just days before Election Day, with voting and mail ballot processing already underway, would be unlawful and unworkable and would disenfranchise eligible voters.

The department argued the matter was urgent. Once signatures on returned mail ballot envelopes are verified, ballots are separated from the envelopes to protect voter confidentiality, which makes it impossible to retrieve an ineligible ballot. Federal prosecutors also contended that votes cast by noncitizens dilute the votes of citizens, though audits and investigations have shown such voting to be extremely rare.

The accuracy of the list remains in dispute. The Los Angeles County review of a small sample found that a significant portion of those listed had said in records that they were born in the United States. Nicolas Bartell, a senior official at U.S. Citizenship and Immigration Services, countered in court filings that his office found none of those individuals were U.S.-born, though he acknowledged four of them "might have a claim to U.S. citizenship." University of Delaware political scientist Kassra Oskooi, an expert witness for voting rights groups intervening in the case, said in a declaration that the agency's matching protocol "is likely to be unreliable."

The lawsuit, filed Oct. 15, is one of several unusual actions the department has taken in states close to Election Day, prompting concern about federal interference in state election procedures. On Monday, federal prosecutors asked Washington state officials to review a list of 400 registered voters the department believes are likely noncitizens. Last week, the department sued in Alaska to try to block certification of the state's Senate race if the Republican incumbent loses because of votes for a longshot candidate with a similar name who is accused of being a spoiler.

California Attorney General Rob Bonta, a Democrat, wrote that the litigation is "a precursor to further interference here in California" and urged the court not to be drawn into "this chilling degradation of democratic values and constitutional principles." The Justice Department is expected to appeal, and the dispute could ultimately reach the U.S. Supreme Court.